Repository navigation
fix(base): preserve the originating press in checkbox changes - #537
Conversation
f8ba8dd to
f07d5f7
Compare
f07d5f7 to
8c30597
Compare
8c30597 to
e8c6977
Compare
|
Reviewed. Checked the full diff against main and issue #398's acceptance: Verification, after rebasing onto main 065ea1b (an unrelated ui/chat change, no conflicts):
Minor, not blocking: the headless tvOS environment now passes Shift and other modifiers on Space/Return, while the device's select press carries none; the roadmap entry already covers mobile keyboard modifiers. |
e8c6977 to
3aa33c1
Compare
Windows delivers Space and Return held with Alt as WM_SYSKEYDOWN, which the backend leaves to DefWindowProc and the window menu, so a real Windows app never presses the focused view with them. The headless Windows environment now does the same instead of reporting an Alt-modified keyboard press.
A Shift-press on a visible label reaches OnChangeEvent with its modifiers at the checkbox origin, and Alt with Space or Return presses the focused checkbox on macOS, Linux and the web but not on Windows.
3aa33c1 to
a22177d
Compare
|
Reviewed. Head a22177d on main fd6adf5; its six commits are patch-identical to the previous head 3aa33c1 (range-diff), only rebased. Code and docs: read the full diff against main and issue #398's acceptance. Mutation checks: passing an empty Verification on this head:
The only red CI job, Not device-checked: physical-keyboard activation on iOS and Android, which this PR leaves as the documented roadmap gap (iOS changes only a comment). |
Summary
Fixes #398.
Add
OnChangeEvent(checked bool, press core.PressEvent)tobase.Checkboxandui.Checkbox, so a list can implement Shift-press range selection without type-asserting the rendered view. When provided it replacesOnChange; existing value-only callbacks keep their behavior and the app retains control of the value. TSX receives{ checked, press }, and generated declarations use the existingPressEventtype so modifiers are available to the type checker too.Keep modifiers when a focused desktop or web pressable is activated with Space or Return, after shortcut handling. Windows delivers Space and Return held with Alt as system keys (
WM_SYSKEYDOWN) that go to the window menu, so they never press a view there; headless input follows the same rules, including the platform-specific Mod mapping and the Windows Alt exception. A press on a visible label (LabelFor, from main) forwards its modifiers to the checkbox. Checkbox pointer/keyboard regressions run in the Linux, Windows, macOS and Chromium input jobs. Physical-keyboard activation on mobile remains an explicit roadmap gap; pointer-event metadata is shared by every target.Targets
base,ui,core,tsx,nsgotest)Screenshots
None: default appearance is unchanged.
Verification
Rebased onto main
fd6adf5c. Main's workflow now runs the wholeinternal/testhost/testdata/presspackage on the macOS, Windows, Linux (xvfb), Chromium and Android emulator jobs, so this PR no longer edits.github/workflows/test.yml:TestCheckboxPressModifiersReachTheAppruns on every desktop and the web there and skips on Android, where physical-keyboard activation is the roadmap gap.ui.CheckboxforwardsRef,LabelledBy,InvalidandOnChangeEvent. The public checkbox docs (English and Chinese) andnsgotest.App.Keynow state the Windows Alt exception.go build ./...andgo tool nsgo check -target all(Linux host): every desktop, Android and web target vets;go tool nsgo check -target iosandGOOS=darwin/iosvets ofinternal/platform/macosandinternal/platform/iospass on macOS.go tool nsgo test ./base: 447 passed, 0 failed, 2 skipped; checkbox tests: 5 passed, covering press metadata, mixed, disabled and controlled values, callback precedence, shortcut priority, macOS/Windows/Linux Mod mapping, Alt on each desktop and the web, and a Shift-press through a visible label.TestCheckboxAltActivationOnWindowsIsTheSystemsKey/windows; replacing the originating press with an empty event failsTestCheckboxChangeEventKeepsThePress.go tool nsgo test ./tsx/ui(7 passed),./tsx(179 passed),./nsgotest(77 passed, 1 skipped),./core(694 passed),./ui(184 passed), headless./internal/testhost/testdata/press(7 passed, 1 macOS-only skip),-run 'Layer|Skills|Doc' .(35 passed).Checklist