module Opal::UI::InputHookable

Overview

Module that equips UI components with per-control input lifecycle hooks, custom input overrides, and code puppeting capabilities.

Direct including types

Defined in:

opal/ui/input_hookable.cr

Instance Method Summary

Instance Method Detail

def custom_inputs=(custom_inputs : Bool) #

[View source]
def custom_inputs? : Bool #

[View source]
def default_input_proc : Proc(InputEvent, Bool) | Nil #

[View source]
def default_input_proc=(default_input_proc : Proc(InputEvent, Bool) | Nil) #

[View source]
def fallback_to_defaults!(enabled : Bool = true) : self #

Sets whether unhandled events in custom input hooks fall back to standard default inputs.


[View source]
def fallback_to_defaults=(fallback_to_defaults : Bool) #

[View source]
def fallback_to_defaults? : Bool #

[View source]
def focus : self #

[View source]
def focused=(focused : Bool) #

[View source]
def focused? : Bool #

[View source]
def handle_default_input(event : InputEvent) : Bool #

Executes the default input logic for this control.


[View source]
def handle_input(event : InputEvent) : Bool #

Routes an incoming input event through custom hooks or default handlers.


[View source]
def handle_key(key : Terminal::KeyEvent) : Bool #

Default key event handler. Override in subclasses if not using @default_input_proc.


[View source]
def handle_mouse(event : Terminal::MouseEvent) : Bool #

Default mouse event handler. Override in subclasses if not using @default_input_proc.


[View source]
def input_hook : Proc(InputEvent, Bool) | Nil #

[View source]
def input_hook=(input_hook : Proc(InputEvent, Bool) | Nil) #

[View source]
def on_input(&block : self, InputEvent -> Bool) : self #

Attaches a custom input hook to this control. The block receives self (strongly typed to the control class) and the InputEvent. Returning true consumes the event. Returning false allows fallback to default inputs (if #fallback_to_defaults? is true).


[View source]
def puppet(&block : self, InputEvent -> Bool) : self #

Programmatically puppet this control from code. Alias for #on_input.


[View source]
def reset_inputs : self #

Clears custom hooks and reinitializes default input bindings.


[View source]
def setup_default_inputs : Nil #

Lifecycle hook: Configures default keyboard and mouse behaviors. May be overridden by subclasses to establish or reset component-specific default input bindings.


[View source]
def unfocus : self #

[View source]
def use_custom_inputs!(enabled : Bool = true) : self #

Enables or disables custom input processing.


[View source]