fix(slint): single click on button primitives (FocusScope stole the first press)

Slint hit-tests sibling children in reverse declaration order, so the
keyboard FocusScope declared after the pointer TouchArea was visited
first and, with the default focus-on-click, consumed the first Pressed
just to grab focus — aborting traversal before the TouchArea, so every
button needed two clicks. Set focus-on-click: false on the FocusScope in
QbzPrimaryButton, SecondaryButton, QbzCheckbox, QbzToggle, ToggleButton
and QbzSelect; the press now reaches the TouchArea on the first click
(Tab/Enter/Space activation unaffected).

cc
This commit is contained in:
vicrodh committed 2026-06-22 21:34:59 -06:00
1 parent 21942c60aa
commit 88f1967d8a
6 files changed
+28 -4

No files matched your search

@@ -50,10 +50,18 @@ export component QbzPrimaryButton inherits Rectangle {
}
}
// Keyboard activation: Enter/Space fire the same click. The TouchArea above
// stays the pointer source; this only adds key activation + focusability.
// Keyboard activation: Enter/Space fire the same click. `focus-on-click:
// false` is LOAD-BEARING: Slint hit-tests siblings in REVERSE declaration
// order, so this FocusScope (declared after `ta`) is visited BEFORE the
// TouchArea. With the default focus-on-click:true an unfocused FocusScope
// eats the first Pressed just to grab keyboard focus, aborting the event
// before it reaches `ta` — THE "blue buttons need two clicks" bug. Disabling
// focus-on-click makes the FocusScope ignore the press (it stays Tab- and
// key-focusable for Enter/Space); the press then falls through to `ta` and
// the first click registers.
fs := FocusScope {
enabled: root.enabled;
focus-on-click: false;
key-pressed(event) => {
if (event.text == Key.Return || event.text == " ") {
root.clicked();