Class: PPCurses::ButtonPair
- Inherits:
-
View
- Object
- Responder
- ResponderManager
- View
- PPCurses::ButtonPair
- Defined in:
- lib/ppcurses/form/button.rb
Overview
For grouping two buttons together, i.e. SUBMIT/CANCEL
Instance Attribute Summary collapse
-
#button1 ⇒ Object
Returns the value of attribute button1.
-
#button2 ⇒ Object
Returns the value of attribute button2.
-
#selected ⇒ Object
Returns the value of attribute selected.
-
#selected_element ⇒ Object
Returns the value of attribute selected_element.
Attributes inherited from View
Attributes inherited from ResponderManager
Attributes inherited from Responder
Instance Method Summary collapse
- #clear ⇒ Object
- #height ⇒ Object
-
#initialize(button1_label, button2_label) ⇒ ButtonPair
constructor
A new instance of ButtonPair.
- #key_down(key) ⇒ Object
- #set_curs_pos(screen) ⇒ Object
- #show(screen) ⇒ Object
Methods inherited from View
#display, #setFrameOrigin, #setFrameSize
Methods inherited from ResponderManager
#accepts_first_responder, #make_first_responder
Methods inherited from Responder
#accepts_first_responder, #become_first_responder, isa, #resign_first_responder
Constructor Details
#initialize(button1_label, button2_label) ⇒ ButtonPair
Returns a new instance of ButtonPair.
64 65 66 67 68 69 70 71 |
# File 'lib/ppcurses/form/button.rb', line 64 def initialize(, ) @button1 = Button.new() @button2 = Button.new() @selected_button = @button1 @selected = false end |
Instance Attribute Details
#button1 ⇒ Object
Returns the value of attribute button1.
61 62 63 |
# File 'lib/ppcurses/form/button.rb', line 61 def @button1 end |
#button2 ⇒ Object
Returns the value of attribute button2.
62 63 64 |
# File 'lib/ppcurses/form/button.rb', line 62 def @button2 end |
#selected ⇒ Object
Returns the value of attribute selected.
58 59 60 |
# File 'lib/ppcurses/form/button.rb', line 58 def selected @selected end |
#selected_element ⇒ Object
Returns the value of attribute selected_element.
59 60 61 |
# File 'lib/ppcurses/form/button.rb', line 59 def selected_element @selected_element end |
Instance Method Details
#clear ⇒ Object
120 121 122 |
# File 'lib/ppcurses/form/button.rb', line 120 def clear # NOP end |
#height ⇒ Object
78 79 80 |
# File 'lib/ppcurses/form/button.rb', line 78 def height 2 end |
#key_down(key) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/ppcurses/form/button.rb', line 86 def key_down( key ) if key == KEY_RIGHT or key == KEY_LEFT @selected_button.selected=false if @selected_button == @button1 @selected_button = @button2 else @selected_button = @button1 end @selected_button.selected=true return end @selected_button.key_down(key) end |
#set_curs_pos(screen) ⇒ Object
82 83 84 |
# File 'lib/ppcurses/form/button.rb', line 82 def set_curs_pos(screen) Curses.curs_set(INVISIBLE) end |
#show(screen) ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/ppcurses/form/button.rb', line 104 def show(screen) p = screen.cur_point p.y+=1 screen.set_pos_by_point(p) @button1.show(screen) p.x += @button1.width + 2 screen.set_pos_by_point(p) @button2.show(screen) end |