Repository navigation
fix(ui): keep a ContextMenu's rows apart from its target's parts - #37
Closed
xiaoyumuxi wants to merge 1 commit into
Closed
xiaoyumuxi wants to merge 1 commit into
xiaoyumuxi wants to merge 1 commit into
Conversation
A ContextMenu declared its rows, backdrop and scroll bar in the scope of its target, tree.Sub(id.Scope(), id.Name()). That is also the scope Control gives the parts of a control (Handlers.Parts), and the scope a container's children live in. So row i of the menu was the identity parts.At(3+i), the backdrop parts.At(1) and the bar parts.At(2): a press on a row was routed to the control's Pointer as a press on its part, and a control that handled it took the click, so the row was never chosen. A text editor that names its scroll bars parts.At(2) and parts.At(3) could never choose the first row of its own context menu by pointer. The open menu now takes a place of its own under the target's scope (~menu). Its state is still kept at the target's scope, so a closed ContextMenu costs a paint nothing more.
This was referenced Nov 17, 2026
|
Superseded: upstream merged the same branch as vivaui#341 (b4ee5fd), which fork main now contains through #39. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Upstream: vivaui#341 (same branch).
This branch is based on upstream
aa89181, which forkmainalready contains, so it merges cleanly. Lithe needs it so the first row of the editor and gutter context menus can be clicked. The Viva maintainers bump thereplacepin in Lithe after this is merged.What this changes
An open
ContextMenunow declares its rows, its backdrop and its scroll bar in a place of its own under the target's scope (~menu), instead of in the target's scope itself. The menu's state is still kept at the target's scope, so nothing changes for a closed menu.ContextMenuAtalready had a scope of its own (bound to its*bool) and is unchanged.Why
contextMenuusedtree.Sub(id.Scope(), id.Name())of the target as the menu's scope.Controlhands out the same scope as the control's parts (Handlers.Parts), and a container givenHithas its children there too. So for aContextMenuon a control with parts:iwas the identityparts.At(3+i), the backdropparts.At(1)and the barparts.At(2);Page.controlOffound the control for each of them (h.parts == id.Scope()) and routed the press to itsPointeras a press on that part;Handled, the painter then delivered no click, and the row was never chosen.We hit it in a text editor that names its scroll bars
parts.At(2)andparts.At(3): the first row of its context menu (Find) could never be chosen with the pointer, while the second row worked. The keyboard worked, because keys focus the row directly.How it was verified
On macOS 27 (arm64):
test -z "$(gofmt -l $(git ls-files '*.go'))"go vet ./...go test ./... -count=1: every package passes exceptcmd/viva, whose packaging tests fail on this machine with "the program was built for macOS 13.0 or later but [mac] min_system says 12.0". They fail the same way onaa89181without this change, so the cause is the local toolchain, not this change.ContextMenu, so I ran a temporary one (not committed). It paints a page of 200 targets, each with a closedContextMenu,-count 6, onaa89181and on this branch: about 113 µs/op both times, 0 allocs/op.BenchmarkMenuOpenandBenchmarkTreealso show no change. A first version that made the~menuscope on every paint cost about 5% on that page, which is why the scope is now made only while the menu is open.TestControlContextMenuIsNotItsParts(inui/control_parts_test.go) puts aContextMenuon the five-star ratingControland checks that:Without the fix it fails at once with
a click on Clear chose [], menu shown true, because the first row's press went to star 4.Where the boundary sits
Framework capability: it fixes how
ContextMenunames what it declares. There is no product behaviour.Cost
Nothing for a closed menu. An open context menu does one more interned scope lookup per paint.