mizchi/tui/events does not have a README file

    ClickHandler

    pub struct ClickHandler(() -> Unit)

    Click handler type

    ClickHandler::new

    fn ClickHandler::new(handler : () -> Unit) -> ClickHandler

    Create a new click handler

    EventHandlers

    pub struct EventHandlers {
    click_handlers : Map[String, ClickHandler]
    }

    Event handlers map (component ID -> handler)

    EventHandlers::get_click

    fn EventHandlers::get_click(self : EventHandlers, id : String) -> ClickHandler?

    Get click handler for a component

    EventHandlers::new

    EventHandlers::on_click

    fn EventHandlers::on_click(self : EventHandlers, id : String, handler : ClickHandler) -> Unit

    Register a click handler for a component

    FocusManager

    pub struct FocusManager {
    focus : FocusState
    mode : InputMode
    focusable_ids : Array[String]
    }

    Focus manager for handling focus state and navigation

    FocusManager::blur

    fn FocusManager::blur(self : FocusManager) -> Unit

    Remove focus (blur)

    FocusManager::focus

    fn FocusManager::focus(self : FocusManager, id : String) -> Unit

    Set focus to a specific component

    FocusManager::focus_next

    fn FocusManager::focus_next(self : FocusManager) -> Unit

    Focus the next component in the focusable list (Tab navigation)

    FocusManager::focus_prev

    fn FocusManager::focus_prev(self : FocusManager) -> Unit

    Focus the previous component in the focusable list (Shift+Tab navigation)

    FocusManager::focusable_count

    fn FocusManager::focusable_count(self : FocusManager) -> Int

    Get the number of focusable elements

    FocusManager::get_focused

    fn FocusManager::get_focused(self : FocusManager) -> String?

    Get the currently focused component ID

    FocusManager::get_mode

    fn FocusManager::get_mode(self : FocusManager) -> InputMode

    Get current input mode

    FocusManager::is_editing

    fn FocusManager::is_editing(self : FocusManager) -> Bool

    Check if currently in editing mode

    FocusManager::is_focused

    fn FocusManager::is_focused(self : FocusManager, id : String) -> Bool

    Check if a component is currently focused

    FocusManager::new

    Create a new focus manager

    FocusManager::register

    fn FocusManager::register(self : FocusManager, id : String) -> Unit

    Register a focusable component ID

    FocusManager::start_editing

    fn FocusManager::start_editing(self : FocusManager) -> Unit

    Enter editing mode

    FocusManager::stop_editing

    fn FocusManager::stop_editing(self : FocusManager) -> Unit

    Exit editing mode

    FocusManager::unregister

    fn FocusManager::unregister(self : FocusManager, id : String) -> Unit

    Unregister a focusable component ID

    FocusState

    pub(all) enum FocusState {
    None
    Focused(String)
    }

    Focus state for the application

    HitTestResult

    pub(all) struct HitTestResult {
    id : String
    x : Int
    y : Int
    width : Int
    height : Int
    role :
    Role
    ?
    }

    Hit test result

    InputEvent

    pub(all) enum InputEvent {
    Key(KeyEvent)
    Mouse(MouseEvent)
    Resize(Int, Int)
    Unknown(String)
    } derive(
    Debug
    )

    Input event
    impl Show for InputEvent

    InputEvent::is_arrow

    fn InputEvent::is_arrow(self : InputEvent) -> SpecialKey?

    Check if the input event is an arrow key, returns the direction

    InputEvent::is_backtab

    fn InputEvent::is_backtab(self : InputEvent) -> Bool

    Check if the input event is Shift+Tab or BackTab

    InputEvent::is_char

    fn InputEvent::is_char(self : InputEvent, c : Char) -> Bool

    Check if the input event is a key matching a character (no modifier)

    InputEvent::is_ctrl

    fn InputEvent::is_ctrl(self : InputEvent, c : Char) -> Bool

    Check if the input event is a key with Ctrl modifier

    InputEvent::is_ctrl_c

    fn InputEvent::is_ctrl_c(self : InputEvent) -> Bool

    Check if the input event is Ctrl+C (quit)

    InputEvent::is_enter

    fn InputEvent::is_enter(self : InputEvent) -> Bool

    Check if the input event is Enter

    InputEvent::is_escape

    fn InputEvent::is_escape(self : InputEvent) -> Bool

    Check if the input event is Escape

    InputEvent::is_left_click

    fn InputEvent::is_left_click(self : InputEvent) -> MouseEvent?

    Check if the input event is a left mouse button press

    InputEvent::is_quit

    fn InputEvent::is_quit(self : InputEvent) -> Bool

    Check if the input event is a common quit key (q, Ctrl+C, Escape)

    InputEvent::is_right_click

    fn InputEvent::is_right_click(self : InputEvent) -> MouseEvent?

    Check if the input event is a right mouse button press

    InputEvent::is_scroll_down

    fn InputEvent::is_scroll_down(self : InputEvent) -> Bool

    Check if the input event is a scroll down

    InputEvent::is_scroll_up

    fn InputEvent::is_scroll_up(self : InputEvent) -> Bool

    Check if the input event is a scroll up

    InputEvent::is_tab

    fn InputEvent::is_tab(self : InputEvent) -> Bool

    Check if the input event is Tab

    InputMode

    pub(all) enum InputMode {
    Normal
    Editing
    }

    Input mode for the application

    KeyEvent

    pub(all) enum KeyEvent {
    Char(Char, KeyModifier)
    Special(SpecialKey, KeyModifier)
    } derive(
    Debug
    )

    Keyboard event
    impl Show for KeyEvent

    KeyEvent::is_char

    fn KeyEvent::is_char(self : KeyEvent, c : Char) -> Bool

    Check if key matches a specific character with optional modifier

    KeyEvent::is_ctrl_c

    fn KeyEvent::is_ctrl_c(self : KeyEvent) -> Bool

    Check if key is Ctrl+C

    KeyEvent::is_ctrl_q

    fn KeyEvent::is_ctrl_q(self : KeyEvent) -> Bool

    Check if key is Ctrl+Q (common quit)

    KeyEvent::is_special

    fn KeyEvent::is_special(self : KeyEvent, special : SpecialKey) -> Bool

    Check if key matches a special key

    KeyModifier

    pub(all) enum KeyModifier {
    None
    Shift
    Ctrl
    Alt
    CtrlShift
    CtrlAlt
    ShiftAlt
    CtrlShiftAlt
    } derive(
    Debug
    )

    Key modifiers
    impl Show for KeyModifier

    MouseButton

    pub(all) enum MouseButton {
    Left
    Middle
    Right
    ScrollUp
    ScrollDown
    None
    } derive(
    Debug
    )

    Mouse button
    impl Show for MouseButton

    MouseEvent

    pub(all) struct MouseEvent {
    button : MouseButton
    event_type : MouseEventType
    x : Int
    y : Int
    modifier : KeyModifier
    } derive(
    Debug
    )

    Mouse event
    impl Show for MouseEvent

    MouseEventType

    pub(all) enum MouseEventType {
    Press
    Release
    Move
    Drag
    } derive(
    Debug
    )

    Mouse event type

    SpecialKey

    pub(all) enum SpecialKey {
    Up
    Down
    Left
    Right
    Home
    End
    PageUp
    PageDown
    Insert
    Delete
    Tab
    BackTab
    Backspace
    Enter
    Escape
    F(Int)
    } derive(
    Debug
    )

    Special keys
    impl Show for SpecialKey

    dump_layout

    fn dump_layout(layout :
    Layout
    , offset_x : Int, offset_y : Int, depth : Int) -> String

    Debug: dump layout tree structure

    find_layout_by_id

    fn find_layout_by_id(layout :
    Layout
    , target_id : String, offset_x : Int, offset_y : Int) -> HitTestResult?

    Find layout by ID Returns the position and size of the component with the given ID

    find_layout_by_id_root

    fn find_layout_by_id_root(layout :
    Layout
    , target_id : String) -> HitTestResult?

    Find layout by ID from root

    handle_click

    fn handle_click(layout :
    Layout
    , handlers : EventHandlers, mouse_x : Int, mouse_y : Int) -> Bool

    Handle mouse click event Returns true if a handler was invoked

    hit_test

    fn hit_test(layout :
    Layout
    , mouse_x : Int, mouse_y : Int, offset_x : Int, offset_y : Int) -> HitTestResult?

    Perform hit test on layout tree Returns the deepest (most specific) node containing the point

    hit_test_root

    fn hit_test_root(layout :
    Layout
    , mouse_x : Int, mouse_y : Int) -> HitTestResult?

    Hit test from root (convenience function)

    layout_rects_root

    fn layout_rects_root(layout :
    Layout
    ) -> Array[HitTestResult]

    Flatten layout tree into rects (root is included).

    parse_input

    fn parse_input(input : String) -> InputEvent

    Parse escape sequence

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io