class

Opal::UI::Engine

Inherits Reference < Object

Focus coordinator and input router for interactive Control instances. Coordinates Tab / Shift+Tab focus navigation, dispatches keyboard and mouse events to the active control, and provides synthetic event injection for automated testing and puppeting.

Constructors

new(controls : Enumerable(Control) = [] of Control)
Source

Instance methods

add(control : Control) : self

Adds a control to the engine. If it's the first control, it receives focus.

Source
blur

Blurs all controls (unsets focused? on all).

Source
controls
Source
controls=(controls : Array(Control))
Source
focus(control : Control) : self

Moves focus to the given control.

Source
focus_at(index : Int32) : self

Moves focus to the control at the specified index.

Source
focus_next

Cycles focus forward to the next control.

Source
focus_prev

Cycles focus backward to the previous control.

Source
focused_control

Returns the currently focused control, if any.

Source
focused_index
Source
focused_index=(focused_index : Int32)
Source
handle_input(event : InputEvent) : Bool

General input event router (dispatches KeyEvent or MouseEvent).

Source
handle_key(key : Terminal::KeyEvent) : Bool

Dispatches a key event. Intercepts Tab / Shift+Tab for navigation if enabled, otherwise routes to the focused control.

Source
handle_mouse(mouse : Terminal::MouseEvent) : Bool

Dispatches a mouse event to the focused control.

Source
on_focus_change
Source
on_focus_change=(on_focus_change : Proc(Control | Nil, Control | Nil, Nil) | Nil)
Source
puppet(control : Control, &block : Control, InputEvent -> Bool) : self

Attaches a puppeting hook to a managed control.

Source
puppet_step

Executes an arbitrary mutation step on the currently focused control.

Source
remove(control : Control) : self

Removes a control from the engine and adjusts the active focus.

Source
send_key(name : String, char : Char | Nil = nil, ctrl : Bool = false, alt : Bool = false, shift : Bool = false) : Bool

Injects a synthetic key event for automated scripting or testing.

Source
send_mouse(x : Int32, y : Int32, button : Terminal::MouseButton = Terminal::MouseButton::Left, action : Terminal::MouseAction = Terminal::MouseAction::Press, ctrl : Bool = false, alt : Bool = false, shift : Bool = false) : Bool

Injects a synthetic mouse event for automated scripting or testing.

Source
tab_navigation=(tab_navigation : Bool)
Source
tab_navigation?
Source