Raxol.LiveView.InputAdapter (Raxol LiveView v2.7.0)

Copy Markdown View Source

Translates browser keyboard events into Raxol.Core.Events.Event structs.

This is the LiveView counterpart of Raxol.Terminal.ANSI.InputParser, which does the same translation for terminal ANSI escape sequences.

Summary

Functions

Translates a terminal click (cell coordinates computed by the browser hook from the pixel offset and cell metrics) into a mouse press Raxol.Core.Events.Event.

Translates a browser keydown event map into a Raxol.Core.Events.Event.

Functions

translate_click_event(arg1)

@spec translate_click_event(map()) :: Raxol.Core.Events.Event.t() | nil

Translates a terminal click (cell coordinates computed by the browser hook from the pixel offset and cell metrics) into a mouse press Raxol.Core.Events.Event.

The dispatcher hit-tests %{action: :press, x: x, y: y} against the positioned layout, so a click lands on whatever on_click element covers that cell: buttons rendered in the browser behave like buttons under a terminal mouse driver.

Returns nil for malformed coordinates rather than raising: the params arrive from a browser client.

translate_key_event(params)

@spec translate_key_event(map()) :: Raxol.Core.Events.Event.t()

Translates a browser keydown event map into a Raxol.Core.Events.Event.

The input params map is expected to have keys like "key", "ctrlKey", "altKey", "shiftKey", and "metaKey" as provided by Phoenix LiveView's phx-window-keydown binding.