Skip to content

[Phase 7E] Mouse routing: click-to-focus, click-to-select, scroll-wheel #34

@fissible

Description

@fissible

What

Wire mouse events from parsed SGR sequences (#32) through the hit-test registry (#31) to widget on_mouse handlers.

App shell changes (src/shell.sh):

  • When shellframe_read_key returns SHELLFRAME_KEY_MOUSE, call shellframe_widget_at $SHELLFRAME_MOUSE_ROW $SHELLFRAME_MOUSE_COL to identify the target widget.
  • If the target widget is not focused, call shellframe_shell_focus_set to move focus to it (click-to-focus).
  • Dispatch to the target widget's on_mouse handler: ${PREFIX}_on_mouse "$SHELLFRAME_MOUSE_BUTTON" "$SHELLFRAME_MOUSE_ACTION" "$SHELLFRAME_MOUSE_ROW" "$SHELLFRAME_MOUSE_COL".

Widget on_mouse handlers:

  • shellframe_list_on_mouse — click on a row sets selection to that row; scroll-wheel scrolls the list
  • shellframe_scroll_on_mouse — scroll-wheel scrolls the container (used by editor, grid)
  • Other widgets: click-to-focus only (no additional action needed for v1)

Files

  • src/shell.sh — mouse dispatch in main loop
  • src/widgets/list.shshellframe_list_on_mouse
  • src/scroll.sh — scroll-wheel handler (used by list, editor, grid)

Done criteria

  • Clicking a widget that is not focused moves focus to it
  • Clicking a row in a list selects that row
  • Scroll-wheel up/down scrolls a focused list or scroll container
  • Clicking outside all registered widgets is a no-op
  • Integration test: click on a list item → selection changes to the clicked row
  • IO validation required (CLAUDE.md §5): Mouse dispatch must be tested through a real PTY with a synthesized SGR mouse event — not just unit-tested with a mock key value

Effort

M (~half day)

Deps

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions