Raxol.Core.Events.Event (Raxol v0.2.0)
View SourceDefines the structure for events in the Raxol system, providing a standardized format for key presses, mouse actions, and other UI events that components need to process.
Events are structs with a :type and :data field, where :type indicates the event category (e.g., :key, :mouse, :resize) and :data contains the event-specific details.
Summary
Functions
Creates a cursor event.
Creates a simple custom event.
Creates a custom event.
Creates a focus event.
Creates a simple key event with pressed state and no modifiers.
Creates a keyboard event.
Creates a simple mouse event with pressed state and no modifiers.
Creates a mouse event with drag state.
Creates a mouse event.
Creates a new event with the given type and data.
Creates a paste event.
Creates a scroll event.
Creates a selection event.
Creates a simple timer event.
Creates a timer event.
Creates a simple window event.
Creates a window event.
Types
@type cursor_event() :: %{ visible: boolean(), style: :block | :line | :underscore, blink: boolean(), position: {non_neg_integer(), non_neg_integer()} }
@type event_data() :: any()
@type event_type() :: atom()
@type focus_event() :: %{target: focus_target(), focused: boolean()}
@type focus_target() :: :component | :window | :application
@type key_state() :: :pressed | :released | :repeat
@type modifiers() :: [atom()]
@type mouse_button() :: :left | :right | :middle
@type mouse_event() :: %{ button: mouse_button() | nil, state: mouse_state() | nil, position: mouse_position(), modifiers: modifiers() }
@type mouse_position() :: {non_neg_integer(), non_neg_integer()}
@type mouse_state() :: :pressed | :released | :double_click
@type paste_event() :: %{ text: String.t(), position: {non_neg_integer(), non_neg_integer()} }
@type scroll_direction() :: :vertical | :horizontal
@type scroll_event() :: %{ direction: scroll_direction(), delta: integer(), position: {non_neg_integer(), non_neg_integer()} }
@type selection_event() :: %{ start_pos: {non_neg_integer(), non_neg_integer()}, end_pos: {non_neg_integer(), non_neg_integer()}, text: String.t() }
@type t() :: %Raxol.Core.Events.Event{data: event_data(), type: event_type()}
@type window_event() :: %{ width: non_neg_integer(), height: non_neg_integer(), action: :resize | :focus | :blur }
Functions
Creates a cursor event.
Parameters
visible
- Whether cursor is visiblestyle
- Cursor styleblink
- Whether cursor should blinkposition
- Cursor position
Creates a simple custom event.
Creates a custom event.
Parameters
data
- Custom event data
Creates a focus event.
Parameters
target
- What received/lost focusfocused
- Whether focus was gained (true) or lost (false)
Creates a simple key event with pressed state and no modifiers.
Creates a keyboard event.
Parameters
key
- The key that was pressed/released (e.g. :enter, :backspace, "a")state
- The state of the key (:pressed, :released, :repeat)modifiers
- List of active modifiers (e.g. [:shift, :ctrl])
Creates a simple mouse event with pressed state and no modifiers.
Creates a mouse event with drag state.
Creates a mouse event.
Parameters
button
- The mouse button (:left, :right, :middle)position
- The mouse position as {x, y}state
- The button state (:pressed, :released, :double_click)modifiers
- List of active modifiers (e.g. [:shift, :ctrl])
Creates a new event with the given type and data.
Creates a paste event.
Parameters
text
- Pasted textposition
- Paste position
Creates a scroll event.
Parameters
direction
- Scroll directiondelta
- Amount scrolled (positive or negative)position
- Current scroll position
Creates a selection event.
Parameters
start_pos
- Selection start positionend_pos
- Selection end positiontext
- Selected text
Creates a simple timer event.
Creates a timer event.
Parameters
data
- Timer-specific data
Creates a simple window event.
Creates a window event.
Parameters
width
- The window widthheight
- The window heightaction
- The window action (:resize, :focus, :blur)