Closed MauAbata closed 2 years ago
You must use the .content {}
method to re-open the tab content and add new tab items in. The .content {}
method works on all GUI controls.
Here is the code updated to add tab items properly and also open the file content inside the tab item:
require 'glimmer-dsl-libui'
include Glimmer
open_files = []
menu('File') {
menu_item('Open work file...') {
on_clicked do
file = open_file
puts file
unless file.nil?
open_files.push file
@tab.content { # re-open tab content and add a new tab item
filename = File.basename(file)
tab_item(filename) {
non_wrapping_multiline_entry {
text File.read(file)
}
}
}
end
end
}
quit_menu_item
}
main = window('File Tabs', 900, 600) {
@tab = tab {
open_files.each do |filename|
tab_item(filename)
end
}
}
main.show
Tab 1 | Tab 2 | Tab 3 |
---|---|---|
Cheers!
Hey there,
I'm trying to create an application that has a tab item for each opened file, for example. Currently, the only way I can see to declare tabs is during the initial declaration of the app, but I do not see any way to add new items or edit the tabs after the app is initialized.
Here's a skeleton of the code I'm working on:
Any help would be appreciated.