Class: Nuklear::UI::Checkbox
Direct Known Subclasses
Instance Attribute Summary collapse
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #checked=(checked) ⇒ Object (also: #selected=)
- #checked? ⇒ Boolean (also: #selected?)
-
#initialize(text, checked: false, enabled: true, &block) ⇒ Checkbox
constructor
A new instance of Checkbox.
- #result(event, context) ⇒ Object
- #to_command ⇒ Object
Methods inherited from Base
Methods included from Enableable
#disable, #disabled=, #disabled?, #enable, #enabled=, #enabled?
Methods included from Events
#event_listeners_for, #on, #trigger
Constructor Details
#initialize(text, checked: false, enabled: true, &block) ⇒ Checkbox
Returns a new instance of Checkbox.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/nuklear/ui/checkbox.rb', line 6 def initialize(text, checked: false, enabled: true, &block) super enabled: enabled @text = text @checked = checked on(true) { @checked = true } on(false) { @checked = false } if block_given? on true, &block on false, &block end end |
Instance Attribute Details
#text ⇒ Object
Returns the value of attribute text.
4 5 6 |
# File 'lib/nuklear/ui/checkbox.rb', line 4 def text @text end |
Instance Method Details
#checked=(checked) ⇒ Object Also known as: selected=
22 23 24 25 |
# File 'lib/nuklear/ui/checkbox.rb', line 22 def checked=(checked) @checked = checked @last_event = checked end |
#checked? ⇒ Boolean Also known as: selected?
18 19 20 |
# File 'lib/nuklear/ui/checkbox.rb', line 18 def checked? @checked end |
#result(event, context) ⇒ Object
34 35 36 |
# File 'lib/nuklear/ui/checkbox.rb', line 34 def result(event, context) trigger event end |
#to_command ⇒ Object
30 31 32 |
# File 'lib/nuklear/ui/checkbox.rb', line 30 def to_command [ :ui_checkbox, text, checked? ] end |