fix(client): stop focus scopes from swallowing the first click on buttons

Every button, row and theme card stacked a FocusScope above its TouchArea.
In Slint 1.18 a FocusScope has focus-on-click enabled by default and accepts
the pointer press while it does not yet hold focus, so the press never
reached the TouchArea below. The first click only moved focus, the second
click (focus already there) activated the control. This is the "works only
from the second click" defect, also seen in settings.

All such FocusScopes now set focus-on-click: false (the TouchArea focuses
them explicitly). The message row hover scope and the push-to-talk area
had the same stacking and are fixed too. The headless ui_smoke test now
sends real pointer move/press/release events and asserts that the first
click on the settings buttons activates them; it failed before the fix.
This commit is contained in:
Loki 2026-10-25 09:48:13 +01:00
parent 3d43c98c9e
commit 71ae933d7d
Signed by: boba
GPG key ID: 253067914055423B
8 changed files with 46 additions and 4 deletions

View file

@ -24,8 +24,8 @@ component MessageRow inherits Rectangle {
preferred-height: row-content.preferred-height;
vertical-stretch: 0;
background: row-touch.has-hover || row-focus.has-focus ? Theme.bg-hover : transparent;
row-touch := TouchArea { }
row-focus := FocusScope { }
row-touch := TouchArea { clicked => { row-focus.focus(); } }
row-focus := FocusScope { focus-on-click: false; }
row-content := HorizontalLayout {
padding-left: 22px; padding-right: 22px;
padding-top: root.message.show_author ? 9px : 2px; padding-bottom: root.message.show_author ? 9px : 2px; spacing: 13px;

View file

@ -17,6 +17,7 @@ export component DeviceSelect inherits Rectangle {
}
TouchArea { clicked => { keyboard.focus(); popup.show(); } }
keyboard := FocusScope {
focus-on-click: false;
key-pressed(event) => {
if event.text == " " || event.text == "\n" { popup.show(); return accept; }
if event.text == Key.DownArrow || event.text == Key.UpArrow {
@ -66,6 +67,7 @@ export component AudioSlider inherits Rectangle {
moved => { if self.pressed { root.update-value(root.minimum + Math.clamp((self.mouse-x - 8px) / (root.width - 16px), 0, 1) * (root.maximum - root.minimum)); } }
}
keyboard := FocusScope {
focus-on-click: false;
key-pressed(event) => {
if event.text == Key.LeftArrow || event.text == Key.RightArrow { root.update-value(root.value + (event.text == Key.RightArrow ? 1 : -1)); return accept; }
return reject;

View file

@ -27,7 +27,7 @@ component SettingsNav inherits Rectangle {
}
}
touch := TouchArea { clicked => { keyboard.focus(); root.clicked(); } }
keyboard := FocusScope { key-pressed(event) => { if event.text == " " || event.text == "\n" { root.clicked(); return accept; } return reject; } }
keyboard := FocusScope { focus-on-click: false; key-pressed(event) => { if event.text == " " || event.text == "\n" { root.clicked(); return accept; } return reject; } }
}
export component SettingsWindow inherits Rectangle {

View file

@ -71,7 +71,7 @@ component ThemeChoice inherits Rectangle {
}
}
pointer := TouchArea { clicked => { keyboard.focus(); root.clicked(); } }
keyboard := FocusScope { key-pressed(event) => { if event.text == " " || event.text == "\n" { root.clicked(); return accept; } return reject; } }
keyboard := FocusScope { focus-on-click: false; key-pressed(event) => { if event.text == " " || event.text == "\n" { root.clicked(); return accept; } return reject; } }
}
export component AppearanceSettings inherits Rectangle {

View file

@ -26,6 +26,7 @@ component NavRow inherits Rectangle {
}
touch := TouchArea { clicked => { keyboard.focus(); root.clicked(); } }
keyboard := FocusScope {
focus-on-click: false;
key-pressed(event) => {
if event.text == " " || event.text == "\n" { root.clicked(); return accept; }
return reject;

View file

@ -62,6 +62,7 @@ export component ActionButton inherits Rectangle {
}
touch := TouchArea { clicked => { keyboard.focus(); root.clicked(); } }
keyboard := FocusScope {
focus-on-click: false;
key-pressed(event) => {
if event.text == " " || event.text == "\n" { root.clicked(); return accept; }
return reject;

View file

@ -68,6 +68,7 @@ export component VoicePanel inherits Rectangle {
changed pressed => { root.ptt-held(self.pressed); }
}
ptt-focus := FocusScope {
focus-on-click: false;
key-pressed(event) => { if event.text == " " { root.ptt-held(true); return accept; } return reject; }
key-released(event) => { if event.text == " " { root.ptt-held(false); return accept; } return reject; }
changed has-focus => { if !self.has-focus { root.ptt-held(false); } }