Skip to content

ui: a Tree's rows are inside the box Tree returns for Box.Shortcut - #9

Closed
xiaoyumuxi wants to merge 1 commit into
mainfrom
fix/tree-row-shortcut
Closed

xiaoyumuxi wants to merge 1 commit into
mainfrom
fix/tree-row-shortcut

Conversation

@xiaoyumuxi

Copy link
Copy Markdown

What this changes

Box.Shortcut on the box Tree returns now acts while one of the tree's rows has the keyboard focus, as it already does for List. listRowScope, which gives a Shortcut the scope a List names its rows in, looked only at the Lists of the paint; it now looks at the Trees too. The Box.Shortcut documentation says Tree rows count as inside the box, and TestTreeShortcutActsWhileARowHasFocus mirrors TestListShortcutActsWhileARowHasFocus.

Why

A Tree builds on a ListState and names its rows in their own scope (TreeState.rows), outside the scroll area's scope, exactly as a List does. Without the row scope, a Shortcut on a Tree matched only while the scroll area itself had the focus, which a click or an arrow key never leaves it with. Seen in Lithe: F4 on the project tree, which opens the selected file, never fired once a row was clicked or reached with the arrows.

How it was verified

  • test -z "$(gofmt -l $(git ls-files '*.go'))"
  • go vet ./...
  • go test ./... -count=1 except cmd/viva, whose 15 packaging tests fail on this machine on base too (Go 1.27.3 and an Xcode SDK that builds for macOS 13.0 or later while the test manifests say min_system = 12.0); everything else passes
  • the new test fails without the change (the Tree's F4 acted 0 times with a row focused) and passes with it
  • platform vet: backends not touched
  • benchmarks: listRowScope runs once per Box.Shortcut declaration and now also walks the paint's Trees, usually a handful
  • a real window: covered by the headless test; the routing is the same on every backend

Where the boundary sits

Framework: which focused elements Box.Shortcut counts as inside a Tree.

Cost

One more short loop when a Shortcut is declared on a box that is not a List.

Box.Shortcut on the box a List returns covers the List's rows, which are
named in their own scope, through listRowScope. A Tree builds on a
ListState and names its rows in the same way, but listRowScope looked only
at the Lists of the paint, so a Shortcut on a Tree acted only while the
scroll area itself had the focus, never while a row had it: an F4 that
opens the selected file of a project tree did nothing once a row was
clicked or reached with the arrows. listRowScope now looks at the Trees
too.
@xiaoyumuxi

Copy link
Copy Markdown
Author

上游已以 vivaui#234 合入同等改动,fork main 已通过上游同步 #21(merge commit 7df24f7)包含它,这里不再单独合入。Upstream merged the same change as vivaui#234; fork main carries it through the upstream sync #21 (merge commit 7df24f7).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant