Module: Thaum::Sigil
- Included in:
- Button, Checkbox, ProgressBar, ScrollView, Select, Spinner, StatusBar, Table, Tabs, Text, TextInput
- Defined in:
- lib/thaum/sigil.rb
Instance Attribute Summary collapse
-
#handler_parent ⇒ Object
Returns the value of attribute handler_parent.
-
#rect ⇒ Object
Returns the value of attribute rect.
-
#thaum_app ⇒ Object
Returns the value of attribute thaum_app.
Instance Method Summary collapse
- #emit(event) ⇒ Object
- #focusable? ⇒ Boolean
-
#focused? ⇒ Boolean
The safe-nav ‘&.` makes `focused_sigil` nil when no app is set; nil.equal?(self) is false.
- #on_blur ⇒ Object
- #on_focus ⇒ Object
-
#on_key(event) ⇒ Object
Terminal event handlers — defaults propagate via emit.
-
#on_mount ⇒ Object
Lifecycle — override for side effects.
- #on_mouse(event) ⇒ Object
- #on_paste(event) ⇒ Object
- #on_tick(event) ⇒ Object
- #on_unmount ⇒ Object
- #on_update(context) ⇒ Object
-
#render(canvas:, theme:) ⇒ Object
Rendering — override in subclass.
- #request_render ⇒ Object
Instance Attribute Details
#handler_parent ⇒ Object
Returns the value of attribute handler_parent.
5 6 7 |
# File 'lib/thaum/sigil.rb', line 5 def handler_parent @handler_parent end |
#rect ⇒ Object
Returns the value of attribute rect.
5 6 7 |
# File 'lib/thaum/sigil.rb', line 5 def rect @rect end |
#thaum_app ⇒ Object
Returns the value of attribute thaum_app.
5 6 7 |
# File 'lib/thaum/sigil.rb', line 5 def thaum_app @thaum_app end |
Instance Method Details
#emit(event) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/thaum/sigil.rb', line 12 def emit(event) app = @thaum_app or return raise Thaum::EmitFromUpdateError, "emit called from on_update" if app.in_on_update if event.is_a?(Thaum::TickEvent) || event.is_a?(Thaum::ResizeEvent) warn "[Thaum] dropping #{event.class} from #{self.class}: " \ "framework-internal events cannot be emitted from Sigils or Actions" return end (@handler_parent || app).dispatch_from_child(event) end |
#focusable? ⇒ Boolean
9 |
# File 'lib/thaum/sigil.rb', line 9 def focusable? = true |
#focused? ⇒ Boolean
The safe-nav ‘&.` makes `focused_sigil` nil when no app is set; nil.equal?(self) is false.
8 |
# File 'lib/thaum/sigil.rb', line 8 def focused? = @thaum_app&.focused_sigil.equal?(self) |
#on_blur ⇒ Object
37 |
# File 'lib/thaum/sigil.rb', line 37 def on_blur; end |
#on_focus ⇒ Object
36 |
# File 'lib/thaum/sigil.rb', line 36 def on_focus; end |
#on_key(event) ⇒ Object
Terminal event handlers — defaults propagate via emit
29 |
# File 'lib/thaum/sigil.rb', line 29 def on_key(event) = emit(event) |
#on_mount ⇒ Object
Lifecycle — override for side effects
34 |
# File 'lib/thaum/sigil.rb', line 34 def on_mount; end |
#on_mouse(event) ⇒ Object
30 |
# File 'lib/thaum/sigil.rb', line 30 def on_mouse(event) = emit(event) |
#on_paste(event) ⇒ Object
31 |
# File 'lib/thaum/sigil.rb', line 31 def on_paste(event) = emit(event) |
#on_tick(event) ⇒ Object
39 |
# File 'lib/thaum/sigil.rb', line 39 def on_tick(event); end |
#on_unmount ⇒ Object
35 |
# File 'lib/thaum/sigil.rb', line 35 def on_unmount; end |
#on_update(context) ⇒ Object
38 |
# File 'lib/thaum/sigil.rb', line 38 def on_update(context); end |
#render(canvas:, theme:) ⇒ Object
Rendering — override in subclass
26 |
# File 'lib/thaum/sigil.rb', line 26 def render(canvas:, theme:); end |
#request_render ⇒ Object
10 |
# File 'lib/thaum/sigil.rb', line 10 def request_render = @thaum_app&.request_render |