Class: PPCurses::Button
- Inherits:
-
View
- Object
- Responder
- ResponderManager
- View
- PPCurses::Button
- Defined in:
- lib/ppcurses/form/button.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#label ⇒ Object
Returns the value of attribute label.
-
#pushed ⇒ Object
Returns the value of attribute pushed.
-
#selected ⇒ Object
Returns the value of attribute selected.
Attributes inherited from View
Attributes inherited from ResponderManager
Attributes inherited from Responder
Instance Method Summary collapse
- #clear ⇒ Object
- #height ⇒ Object
-
#initialize(label) ⇒ Button
constructor
A new instance of Button.
- #key_down(key) ⇒ Object
- #set_curs_pos(screen) ⇒ Object
-
#show(screen) ⇒ Object
Screen should be of type Curses::Window.
- #width ⇒ 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(label) ⇒ Button
Returns a new instance of Button.
11 12 13 14 15 |
# File 'lib/ppcurses/form/button.rb', line 11 def initialize(label) @label = label @selected = false @pushed = false end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
9 10 11 |
# File 'lib/ppcurses/form/button.rb', line 9 def action @action end |
#label ⇒ Object
Returns the value of attribute label.
5 6 7 |
# File 'lib/ppcurses/form/button.rb', line 5 def label @label end |
#pushed ⇒ Object
Returns the value of attribute pushed.
7 8 9 |
# File 'lib/ppcurses/form/button.rb', line 7 def pushed @pushed end |
#selected ⇒ Object
Returns the value of attribute selected.
6 7 8 |
# File 'lib/ppcurses/form/button.rb', line 6 def selected @selected end |
Instance Method Details
#clear ⇒ Object
46 47 48 |
# File 'lib/ppcurses/form/button.rb', line 46 def clear # NOP end |
#height ⇒ Object
30 31 32 |
# File 'lib/ppcurses/form/button.rb', line 30 def height 1 end |
#key_down(key) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/ppcurses/form/button.rb', line 38 def key_down( key ) if key == ENTER @action.call unless action.nil? end end |
#set_curs_pos(screen) ⇒ Object
34 35 36 |
# File 'lib/ppcurses/form/button.rb', line 34 def set_curs_pos(screen) Curses.curs_set(INVISIBLE) end |
#show(screen) ⇒ Object
Screen should be of type Curses::Window
20 21 22 23 24 |
# File 'lib/ppcurses/form/button.rb', line 20 def show(screen) screen.attron(Curses::A_REVERSE) if @selected screen.addstr("< #{@label} >") screen.attroff(Curses::A_REVERSE) if @selected end |
#width ⇒ Object
26 27 28 |
# File 'lib/ppcurses/form/button.rb', line 26 def width @label.length + 4 end |