Class: Nuklear::UI::EditString
- Defined in:
- lib/nuklear/ui/edit_string.rb
Instance Attribute Summary collapse
-
#filter ⇒ Object
Returns the value of attribute filter.
-
#flags ⇒ Object
Returns the value of attribute flags.
-
#max_length ⇒ Object
Returns the value of attribute max_length.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #demand_focus? ⇒ Boolean
- #focus ⇒ Object
-
#initialize(text: "", flags: 0, max_length: 255, filter: nil, enabled: true) ⇒ EditString
constructor
A new instance of EditString.
- #result(result, context) ⇒ Object
- #to_command ⇒ Object
- #to_commands ⇒ 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: "", flags: 0, max_length: 255, filter: nil, enabled: true) ⇒ EditString
Returns a new instance of EditString.
6 7 8 9 10 11 12 13 |
# File 'lib/nuklear/ui/edit_string.rb', line 6 def initialize(text: "", flags: 0, max_length: 255, filter: nil, enabled: true) super enabled: enabled @text = text @flags = Nuklear.parse_flags :edit, flags @max_length = max_length @filter = filter @demand_focus = false end |
Instance Attribute Details
#filter ⇒ Object
Returns the value of attribute filter.
4 5 6 |
# File 'lib/nuklear/ui/edit_string.rb', line 4 def filter @filter end |
#flags ⇒ Object
Returns the value of attribute flags.
4 5 6 |
# File 'lib/nuklear/ui/edit_string.rb', line 4 def flags @flags end |
#max_length ⇒ Object
Returns the value of attribute max_length.
4 5 6 |
# File 'lib/nuklear/ui/edit_string.rb', line 4 def max_length @max_length end |
#text ⇒ Object
Returns the value of attribute text.
4 5 6 |
# File 'lib/nuklear/ui/edit_string.rb', line 4 def text @text end |
Instance Method Details
#demand_focus? ⇒ Boolean
15 16 17 |
# File 'lib/nuklear/ui/edit_string.rb', line 15 def demand_focus? @demand_focus end |
#focus ⇒ Object
19 20 21 |
# File 'lib/nuklear/ui/edit_string.rb', line 19 def focus @demand_focus = true end |
#result(result, context) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/nuklear/ui/edit_string.rb', line 39 def result(result, context) trigger(:activated) if (result & Nuklear::NK_EDIT_ACTIVATED) > 0 trigger(:deactivated) if (result & Nuklear::NK_EDIT_DEACTIVATED) > 0 trigger(:committed) if (result & Nuklear::NK_EDIT_COMMITED) > 0 trigger(:active) if (result & Nuklear::NK_EDIT_ACTIVE) > 0 trigger(:inactive) if (result & Nuklear::NK_EDIT_INACTIVE) > 0 end |
#to_command ⇒ Object
35 36 37 |
# File 'lib/nuklear/ui/edit_string.rb', line 35 def to_command [:ui_edit_string, flags, text, max_length, filter] end |
#to_commands ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/nuklear/ui/edit_string.rb', line 23 def to_commands if demand_focus? @demand_focus = false [ [:ui_edit_focus, flags], self, ] else [self] end end |