Skip to content

v0.5.0

Choose a tag to compare

@ralyodio ralyodio released this 12 Sep 19:22
7ece82a

Every piece of chrome that looks clickable now takes a click.

A status bar that says F1 Help, a dialog with a Yes button and a panel with a title were all things a mouse could point at, and none of them answered. Rows did, because the scrollable widgets register the region they draw; nothing else registered anything. So an app built on hqtui was keyboard-only at exactly the places a user reaches for the mouse first.

Status bar items take onPress. The bar returns the span it drew for each item and the container registers a region for the key cap and the label only, so the gap between two items belongs to neither.

Modal buttons take onPress, and a modal takes onDismiss for a click on its backdrop. Given one or not, a dialog now owns the screen while it is up: its body and its backdrop both swallow clicks, so a table drawn underneath never selects a row a click was aimed past it at. The button layout is shared between drawing and hit-testing, so the cell that shows a button is the cell that presses it.

Panels take onClick, registered before their children draw, so a panel only answers for the cells nothing inside it claimed: the border, the title row, the blank space under a short list.

A double-click exists. The app counts presses on the same row within 400ms and delivers clicks on the mouse event and to every region. Scrollable widgets turn the second press into onActivateRow, after onSelectRow, which is how a file manager selects and then opens.

Tests can click. The hit-test moved out of the app into dispatchHit, and the headless screen gained click(x, y) and scroll(x, y, delta) that run it, so a test can prove the cell showing F2 Theme is the cell that changes the theme.

The demo's key bar and both of its dialogs are wired through the new hooks. Rendering is untouched, so the port fixtures do not move, and existing code that registers regions or handlers keeps working: the click count is optional on the region handler, and every new option is optional.

Built for DiskPush's TUI, which gets clickable panes, a .. row, footer keys and dialogs on top of it.