class PPCurses::ComboBox
Constants
- DOWN_ARROW
Attributes
selected[RW]
Does the element have focus in the form?
Public Class Methods
new(label, options)
click to toggle source
# File lib/ppcurses/form/combo_box.rb, line 12 def initialize(label, options) @label = label @options = options @display_width = 13 @choice_made = false @options.each do |option| if option.length > @display_width @display_width = option.length end end end
Public Instance Methods
clear()
click to toggle source
# File lib/ppcurses/form/combo_box.rb, line 78 def clear @choice_made = false end
height()
click to toggle source
# File lib/ppcurses/form/combo_box.rb, line 38 def height 1 end
key_down(key)
click to toggle source
# File lib/ppcurses/form/combo_box.rb, line 57 def key_down(key) if key == ENTER if @options_menu.nil? @options_menu = PPCurses::ChoiceMenu.new( @options ) end @options_menu.set_origin(@combo_display_point) @options_menu.show @options_menu.menu_selection if @options_menu.pressed_enter @choice_made = true end end end
object_value_of_selected_item()
click to toggle source
Return Value The object in the receiver's internal item list corresponding to the last item selected from the pop-up list, or nil if no item is selected.
# File lib/ppcurses/form/combo_box.rb, line 49 def object_value_of_selected_item if @options_menu.nil? return nil end @options[@options_menu.selection] end
set_curs_pos(screen)
click to toggle source
# File lib/ppcurses/form/combo_box.rb, line 42 def set_curs_pos(screen) screen.curs_set(INVISIBLE) end
show(screen)
click to toggle source
# File lib/ppcurses/form/combo_box.rb, line 27 def show(screen) screen.attron(A_REVERSE) if @selected screen.addstr("#{@label}:") @combo_display_point = screen.cur_point screen.attroff(A_REVERSE) if @selected screen.addstr(display_string) end
Protected Instance Methods
display_string()
click to toggle source
# File lib/ppcurses/form/combo_box.rb, line 84 def display_string if @choice_made return ' '+ "#{@options[@options_menu.selection].center(@display_width,'-')} #{DOWN_ARROW}" end ' ' + ' select '.center(@display_width,'-') + " #{DOWN_ARROW}" end