ElixirOpentui.EventManager (ElixirOpentui v0.2.0)

Copy Markdown View Source

Routes input events to the correct handlers based on focus state and hit-testing.

Pure module — takes events and state, returns new state and list of actions. No side effects, no processes. The Runtime calls this to process events.

Event flow:

  1. Tab/Shift+Tab → focus navigation
  2. Mouse events → hit-test buffer → resolve target → auto-focus on left click
  3. Resize events → resize action

Summary

Functions

Create an event manager from an element tree.

Process an input event. Returns {new_state, actions} where actions is a list of side effects for the Runtime to execute.

Update the tree and buffer after a render.

Types

state()

@type state() :: %ElixirOpentui.EventManager{
  buffer: ElixirOpentui.Buffer.t() | nil,
  focus: ElixirOpentui.Focus.t(),
  tree: ElixirOpentui.Element.t() | nil
}

Functions

new(tree, buffer)

Create an event manager from an element tree.

process(state, event)

@spec process(state(), ElixirOpentui.Input.event()) :: {state(), [term()]}

Process an input event. Returns {new_state, actions} where actions is a list of side effects for the Runtime to execute.

update(state, tree, buffer)

Update the tree and buffer after a render.