TabbedPanes in ruby-curses
Tabbedpanes (multiple overlapping forms as you see in preference panes) may now
be made quite simply as follows:
@tp = RubyCurses::TabbedPane.new @window do height 12 width 50 row 5 col 10 end ## add a tab with label Language @tab1 = @tp.add_tab "Language" ## get the form associated with the tab, so we can create widgets/fields on it f1 = @tab1.form
## a quick example of some checkboxes is as follows @tab3 = @tp.add_tab "Editors" f3 = @tab3.form butts = %w[ Vim Emacs Jed Other ] row = 3 # starting row butts.each do |name| RubyCurses::CheckBox.new f3 do text name row row col 4 end row +=1 end ## ask the tabbed pane to display itself and to handle keys @tp.show @tp.handle_keys
Buttons have been used for the tab labels on top. Currently, pressing a button reveals the tab form. After tabbing through buttons, focus goes to the open tab. After the last field on the tab, focus comes back to the buttons.
I have looked at various implementations on my system. In the Terminal preferences, pressing the button reveals the tab form. In others, when the button gets focus the tab is revealed. I am not sure what standard behaviour is. Looking for feedback.
I have just coded this. Not much testing. Currently, buttons have 2 states:
unfocussed. However, here we need 3 states:
selected (this button’s tab is open),
focussed (cycling through buttons) and
Please do let me know any other widgets that would be useful. If you can give me a link to details (methods, properties) as well as a description of behaviour that would help.
I got stalled on combo-boxes, since I am not sure of standard behaviour. The examples I see on my system ( in iTunes, Firefox location bar, etc) all have differences in behaviour.