canvas: carry click modifiers into press Msg arms - #318
Open
MohakBajaj wants to merge 1 commit into
Open
Conversation
`WidgetPointerEvent` already knows which modifiers were held at click
time, but nothing forwarded them to app code: `UiApp.Options` has
`on_key`, `on_pinch` and `on_drop` and no pointer hook, so cmd-click and
shift-click were not expressible in either core language.
Carry them on the existing press channel, the way `on-drag` already fills
phase and geometry around an authored `sourceId`. A Msg arm that declares
the four booleans `shift`/`control`/`alt`/`super` beside at most one
authored payload field receives them; markup keeps its ordinary spelling,
so `on-press="select:{row.id}"` fills `id` and the runtime fills the rest.
An arm without all four booleans is an ordinary payload and takes exactly
the path it takes today, so this is additive.
- reflect: `declaredWidgetPressRecord` and `pressPayloadFieldName`
- ui: `msgForPointerClickModified` plus the `withPressModifiers` injector,
with the three-argument form kept as the unmodified entry point
- both engines fill the authored field and leave the modifiers to dispatch
- contract: the `press` payload class and `MsgTag.press_payload`, so a
binding is kind-checked against the authored field; artifact version 7
- automation: `widget-click <view> <id> [cmd|shift|cmd+shift]`, so the
channel is drivable from tests and smoke runs
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Someone is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
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.
The gap
WidgetPointerEventalready carriesmodifiers, and the platform layeralready fills them — but nothing forwards them to app code.
UiApp.Optionshas
on_key,on_pinchandon_dropand no pointer hook, and markup'son-presscarries a tag plus one payload path. So cmd-click andshift-click are not expressible in either core language, in markup or in a
Zig builder view.
I hit this building a capture inbox: multi-select had to fall back to a
context-menu item, because the modifiers the runtime already knew were
dropped one layer before the app.
The change
Carry them on the existing press channel, the way
on-dragalready fillsphase and geometry around an authored
sourceId. A Msg arm that declaresthe four booleans
shift/control/alt/superbeside at mostone authored payload field receives them:
Markup fills
id; the runtime fills the rest at dispatch. A bareon-press="clear"names the modifier-only form. An arm without all fourbooleans is an ordinary payload and takes exactly the path it takes today,
so this is additive — no new attribute, no new vocabulary in the closed
grammar.
What is touched
ui_markup_reflect.zig—declaredWidgetPressRecord,pressPayloadFieldNameui.zig—msgForPointerClickModified+ thewithPressModifiersinjector; the three-argument
msgForPointerClickstays as theunmodified entry point
ui_markup_view.zig,ui_markup_compiled.zig) fill theauthored field and leave the modifiers to dispatch
ui_markup_contract.zig— thepresspayload class andMsgTag.press_payload, so a binding is kind-checked against theauthored field rather than the record; artifact version 6 → 7
widget-click <view> <id> [cmd|shift|cmd+shift], so thechannel is drivable from tests and smoke runs
native-ui/automationskillsVerification
zig build testpasses. The new dispatch test was confirmed to actuallyexecute by forcing it to fail first, then reverting.
zig build test-examples-nativepasses, includingkanban(theadjacent
on-dragpath) and the TypeScript-core examples that exercisethe contract.
clears, shift-click makes a range, shift-click again replaces it,
cmd-click adds discontiguously, plain click clears. Standard macOS list
selection.
scripts/gate.sh fastis green exceptbench-check, which fails the samebudgets worse on clean
mainon this machine (keystroke-big-view3647µs vs 3567µs with the change, against a 3000µs budget) — it is not a
quiet Apple Silicon benchmark host, not a regression here.
Notes for review
zig-out/model-contract.zonregenerates on the next build. It degradesloudly and never falsely passes (I watched an app report "could not be
parsed — run
native test"), but if you would rather have a differentcompatibility story, say so and I will rework it.
clickCountis deliberately excluded. The runtime has it and itwould be nearly free, but
on-double-pressalready covers that groundand a narrower first change seemed easier to judge. Happy to add it.
CHANGELOG.mdis untouched, perAGENTS.md.🤖 Generated with Claude Code