Class: Plushie::Event::Widget
- Inherits:
-
Data
- Object
- Data
- Plushie::Event::Widget
- Defined in:
- lib/plushie/event.rb
Overview
All widget interaction events.
Covers standard widget events (:click, :input, :submit, etc.), unified pointer events (:press, :release, :move, :scroll, :enter, :exit, :double_click, :resize), generic element events (:focused, :blurred, :drag, :drag_end, :key_press, :key_release), pane events (:pane_resized, :pane_dragged, :pane_clicked), animation events (:transition_complete), and subscription pointer events.
The +value+ field carries the event payload. For single-value events (input text, slider position, toggle state) it holds the scalar. For multi-field events (pointer coordinates, pane operations, key data) it holds a symbol-keyed Hash.
No-payload events (click, open, close) always have +value: nil+. Pattern-match without binding +value+ for these:
in Event::Widget[type: :click, id: "save"]
The +scope+ array lists ancestor container IDs from immediate parent to outermost. The window_id is appended as the last element (outermost ancestor). Use Event.target to reconstruct the forward-order path (window_id is stripped).
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#id [String] widget ID that produced the event([String]) ⇒ Object
readonly
All widget interaction events.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
-
#scope [Array<String>] reversed ancestor scope chain (immediate parent first, window_id last)([Array<String>](immediate parent first, window_id last)) ⇒ Object
readonly
All widget interaction events.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#type [Symbol] event kind([Symbol]) ⇒ Object
readonly
All widget interaction events.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
-
#value [Object, nil] event payload (scalar or symbol-keyed Hash)([Object, nil](scalar) ⇒ Object
readonly
All widget interaction events.
-
#window_id ⇒ Object
readonly
Returns the value of attribute window_id.
-
#window_id [String, nil] window that produced the event([String, nil]) ⇒ Object
readonly
All widget interaction events.
Instance Method Summary collapse
-
#drag? ⇒ Boolean
Drag events (drag, drag_end).
-
#focus? ⇒ Boolean
Focus lifecycle events (focused, blurred).
-
#initialize(type:, id:, value: nil, window_id: nil, scope: []) ⇒ Widget
constructor
A new instance of Widget.
-
#keyboard? ⇒ Boolean
Widget-scoped keyboard events (key_press, key_release).
-
#pane? ⇒ Boolean
Pane grid events (pane_resized, pane_dragged, pane_clicked, pane_focus_cycle).
-
#pointer? ⇒ Boolean
Pointer events (press, release, move, scroll, enter, exit, double_click).
-
#spec ⇒ Hash?
Look up the spec for this event's type.
Constructor Details
#initialize(type:, id:, value: nil, window_id: nil, scope: []) ⇒ Widget
Returns a new instance of Widget.
63 64 65 |
# File 'lib/plushie/event.rb', line 63 def initialize(type:, id:, value: nil, window_id: nil, scope: []) super end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id
62 63 64 |
# File 'lib/plushie/event.rb', line 62 def id @id end |
#id [String] widget ID that produced the event([String]) ⇒ Object (readonly)
All widget interaction events.
Covers standard widget events (:click, :input, :submit, etc.), unified pointer events (:press, :release, :move, :scroll, :enter, :exit, :double_click, :resize), generic element events (:focused, :blurred, :drag, :drag_end, :key_press, :key_release), pane events (:pane_resized, :pane_dragged, :pane_clicked), animation events (:transition_complete), and subscription pointer events.
The +value+ field carries the event payload. For single-value events (input text, slider position, toggle state) it holds the scalar. For multi-field events (pointer coordinates, pane operations, key data) it holds a symbol-keyed Hash.
No-payload events (click, open, close) always have +value: nil+. Pattern-match without binding +value+ for these:
in Event::Widget[type: :click, id: "save"]
The +scope+ array lists ancestor container IDs from immediate parent to outermost. The window_id is appended as the last element (outermost ancestor). Use Event.target to reconstruct the forward-order path (window_id is stripped).
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/plushie/event.rb', line 62 Widget = Data.define(:type, :id, :value, :window_id, :scope) do def initialize(type:, id:, value: nil, window_id: nil, scope: []) super end # Category predicates for event type families. # Pointer events (press, release, move, scroll, enter, exit, double_click). def pointer? = Specs::POINTER_TYPES.include?(type) # Widget-scoped keyboard events (key_press, key_release). def keyboard? = Specs::KEYBOARD_TYPES.include?(type) # Pane grid events (pane_resized, pane_dragged, pane_clicked, pane_focus_cycle). def pane? = Specs::PANE_TYPES.include?(type) # Focus lifecycle events (focused, blurred). def focus? = Specs::FOCUS_TYPES.include?(type) # Drag events (drag, drag_end). def drag? = Specs::DRAG_TYPES.include?(type) # Look up the spec for this event's type. # @return [Hash, nil] def spec = Specs.for(type) end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope
62 63 64 |
# File 'lib/plushie/event.rb', line 62 def scope @scope end |
#scope [Array<String>] reversed ancestor scope chain (immediate parent first, window_id last)([Array<String>](immediate parent first, window_id last)) ⇒ Object (readonly)
All widget interaction events.
Covers standard widget events (:click, :input, :submit, etc.), unified pointer events (:press, :release, :move, :scroll, :enter, :exit, :double_click, :resize), generic element events (:focused, :blurred, :drag, :drag_end, :key_press, :key_release), pane events (:pane_resized, :pane_dragged, :pane_clicked), animation events (:transition_complete), and subscription pointer events.
The +value+ field carries the event payload. For single-value events (input text, slider position, toggle state) it holds the scalar. For multi-field events (pointer coordinates, pane operations, key data) it holds a symbol-keyed Hash.
No-payload events (click, open, close) always have +value: nil+. Pattern-match without binding +value+ for these:
in Event::Widget[type: :click, id: "save"]
The +scope+ array lists ancestor container IDs from immediate parent to outermost. The window_id is appended as the last element (outermost ancestor). Use Event.target to reconstruct the forward-order path (window_id is stripped).
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/plushie/event.rb', line 62 Widget = Data.define(:type, :id, :value, :window_id, :scope) do def initialize(type:, id:, value: nil, window_id: nil, scope: []) super end # Category predicates for event type families. # Pointer events (press, release, move, scroll, enter, exit, double_click). def pointer? = Specs::POINTER_TYPES.include?(type) # Widget-scoped keyboard events (key_press, key_release). def keyboard? = Specs::KEYBOARD_TYPES.include?(type) # Pane grid events (pane_resized, pane_dragged, pane_clicked, pane_focus_cycle). def pane? = Specs::PANE_TYPES.include?(type) # Focus lifecycle events (focused, blurred). def focus? = Specs::FOCUS_TYPES.include?(type) # Drag events (drag, drag_end). def drag? = Specs::DRAG_TYPES.include?(type) # Look up the spec for this event's type. # @return [Hash, nil] def spec = Specs.for(type) end |
#type ⇒ Object (readonly)
Returns the value of attribute type
62 63 64 |
# File 'lib/plushie/event.rb', line 62 def type @type end |
#type [Symbol] event kind([Symbol]) ⇒ Object (readonly)
All widget interaction events.
Covers standard widget events (:click, :input, :submit, etc.), unified pointer events (:press, :release, :move, :scroll, :enter, :exit, :double_click, :resize), generic element events (:focused, :blurred, :drag, :drag_end, :key_press, :key_release), pane events (:pane_resized, :pane_dragged, :pane_clicked), animation events (:transition_complete), and subscription pointer events.
The +value+ field carries the event payload. For single-value events (input text, slider position, toggle state) it holds the scalar. For multi-field events (pointer coordinates, pane operations, key data) it holds a symbol-keyed Hash.
No-payload events (click, open, close) always have +value: nil+. Pattern-match without binding +value+ for these:
in Event::Widget[type: :click, id: "save"]
The +scope+ array lists ancestor container IDs from immediate parent to outermost. The window_id is appended as the last element (outermost ancestor). Use Event.target to reconstruct the forward-order path (window_id is stripped).
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/plushie/event.rb', line 62 Widget = Data.define(:type, :id, :value, :window_id, :scope) do def initialize(type:, id:, value: nil, window_id: nil, scope: []) super end # Category predicates for event type families. # Pointer events (press, release, move, scroll, enter, exit, double_click). def pointer? = Specs::POINTER_TYPES.include?(type) # Widget-scoped keyboard events (key_press, key_release). def keyboard? = Specs::KEYBOARD_TYPES.include?(type) # Pane grid events (pane_resized, pane_dragged, pane_clicked, pane_focus_cycle). def pane? = Specs::PANE_TYPES.include?(type) # Focus lifecycle events (focused, blurred). def focus? = Specs::FOCUS_TYPES.include?(type) # Drag events (drag, drag_end). def drag? = Specs::DRAG_TYPES.include?(type) # Look up the spec for this event's type. # @return [Hash, nil] def spec = Specs.for(type) end |
#value ⇒ Object (readonly)
Returns the value of attribute value
62 63 64 |
# File 'lib/plushie/event.rb', line 62 def value @value end |
#value [Object, nil] event payload (scalar or symbol-keyed Hash)([Object, nil](scalar) ⇒ Object (readonly)
All widget interaction events.
Covers standard widget events (:click, :input, :submit, etc.), unified pointer events (:press, :release, :move, :scroll, :enter, :exit, :double_click, :resize), generic element events (:focused, :blurred, :drag, :drag_end, :key_press, :key_release), pane events (:pane_resized, :pane_dragged, :pane_clicked), animation events (:transition_complete), and subscription pointer events.
The +value+ field carries the event payload. For single-value events (input text, slider position, toggle state) it holds the scalar. For multi-field events (pointer coordinates, pane operations, key data) it holds a symbol-keyed Hash.
No-payload events (click, open, close) always have +value: nil+. Pattern-match without binding +value+ for these:
in Event::Widget[type: :click, id: "save"]
The +scope+ array lists ancestor container IDs from immediate parent to outermost. The window_id is appended as the last element (outermost ancestor). Use Event.target to reconstruct the forward-order path (window_id is stripped).
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/plushie/event.rb', line 62 Widget = Data.define(:type, :id, :value, :window_id, :scope) do def initialize(type:, id:, value: nil, window_id: nil, scope: []) super end # Category predicates for event type families. # Pointer events (press, release, move, scroll, enter, exit, double_click). def pointer? = Specs::POINTER_TYPES.include?(type) # Widget-scoped keyboard events (key_press, key_release). def keyboard? = Specs::KEYBOARD_TYPES.include?(type) # Pane grid events (pane_resized, pane_dragged, pane_clicked, pane_focus_cycle). def pane? = Specs::PANE_TYPES.include?(type) # Focus lifecycle events (focused, blurred). def focus? = Specs::FOCUS_TYPES.include?(type) # Drag events (drag, drag_end). def drag? = Specs::DRAG_TYPES.include?(type) # Look up the spec for this event's type. # @return [Hash, nil] def spec = Specs.for(type) end |
#window_id ⇒ Object (readonly)
Returns the value of attribute window_id
62 63 64 |
# File 'lib/plushie/event.rb', line 62 def window_id @window_id end |
#window_id [String, nil] window that produced the event([String, nil]) ⇒ Object (readonly)
All widget interaction events.
Covers standard widget events (:click, :input, :submit, etc.), unified pointer events (:press, :release, :move, :scroll, :enter, :exit, :double_click, :resize), generic element events (:focused, :blurred, :drag, :drag_end, :key_press, :key_release), pane events (:pane_resized, :pane_dragged, :pane_clicked), animation events (:transition_complete), and subscription pointer events.
The +value+ field carries the event payload. For single-value events (input text, slider position, toggle state) it holds the scalar. For multi-field events (pointer coordinates, pane operations, key data) it holds a symbol-keyed Hash.
No-payload events (click, open, close) always have +value: nil+. Pattern-match without binding +value+ for these:
in Event::Widget[type: :click, id: "save"]
The +scope+ array lists ancestor container IDs from immediate parent to outermost. The window_id is appended as the last element (outermost ancestor). Use Event.target to reconstruct the forward-order path (window_id is stripped).
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/plushie/event.rb', line 62 Widget = Data.define(:type, :id, :value, :window_id, :scope) do def initialize(type:, id:, value: nil, window_id: nil, scope: []) super end # Category predicates for event type families. # Pointer events (press, release, move, scroll, enter, exit, double_click). def pointer? = Specs::POINTER_TYPES.include?(type) # Widget-scoped keyboard events (key_press, key_release). def keyboard? = Specs::KEYBOARD_TYPES.include?(type) # Pane grid events (pane_resized, pane_dragged, pane_clicked, pane_focus_cycle). def pane? = Specs::PANE_TYPES.include?(type) # Focus lifecycle events (focused, blurred). def focus? = Specs::FOCUS_TYPES.include?(type) # Drag events (drag, drag_end). def drag? = Specs::DRAG_TYPES.include?(type) # Look up the spec for this event's type. # @return [Hash, nil] def spec = Specs.for(type) end |
Instance Method Details
#drag? ⇒ Boolean
Drag events (drag, drag_end).
82 |
# File 'lib/plushie/event.rb', line 82 def drag? = Specs::DRAG_TYPES.include?(type) |
#focus? ⇒ Boolean
Focus lifecycle events (focused, blurred).
79 |
# File 'lib/plushie/event.rb', line 79 def focus? = Specs::FOCUS_TYPES.include?(type) |
#keyboard? ⇒ Boolean
Widget-scoped keyboard events (key_press, key_release).
73 |
# File 'lib/plushie/event.rb', line 73 def keyboard? = Specs::KEYBOARD_TYPES.include?(type) |
#pane? ⇒ Boolean
Pane grid events (pane_resized, pane_dragged, pane_clicked, pane_focus_cycle).
76 |
# File 'lib/plushie/event.rb', line 76 def pane? = Specs::PANE_TYPES.include?(type) |
#pointer? ⇒ Boolean
Pointer events (press, release, move, scroll, enter, exit, double_click).
70 |
# File 'lib/plushie/event.rb', line 70 def pointer? = Specs::POINTER_TYPES.include?(type) |