Class: Luck::Button
Instance Attribute Summary collapse
-
#handler ⇒ Object
Returns the value of attribute handler.
Attributes inherited from Label
Attributes inherited from Control
#display, #pane, #x1, #x2, #y1, #y2
Instance Method Summary collapse
- #handle_char(char) ⇒ Object
- #handle_click(button, modifiers, x, y) ⇒ Object
- #on_submit(&blck) ⇒ Object
- #redraw ⇒ Object
- #text ⇒ Object
Methods inherited from Label
#align, #align_text, #initialize
Methods inherited from Control
#focus!, #height, #initialize, #width
Constructor Details
This class inherits a constructor from Luck::Label
Instance Attribute Details
#handler ⇒ Object
Returns the value of attribute handler.
3 4 5 |
# File 'lib/luck/button.rb', line 3 def handler @handler end |
Instance Method Details
#handle_char(char) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/luck/button.rb', line 9 def handle_char char if char == "\n" handler.call self, @text if handler end #redraw end |
#handle_click(button, modifiers, x, y) ⇒ Object
16 17 18 |
# File 'lib/luck/button.rb', line 16 def handle_click , modifiers, x, y handler.call self, @text if == :left && handler end |
#on_submit(&blck) ⇒ Object
5 6 7 |
# File 'lib/luck/button.rb', line 5 def on_submit &blck @handler = blck end |
#redraw ⇒ Object
28 29 30 31 32 33 |
# File 'lib/luck/button.rb', line 28 def redraw @display.driver.cursor = false print @display.color(@display.active_control == self ? '1;34' : '0;36') super print @display.color('0') end |
#text ⇒ Object
20 21 22 |
# File 'lib/luck/button.rb', line 20 def text "[ #{@text} ]" end |