Replies: 1 comment 2 replies
-
|
I also encountered a similar issue, and then found the solution here, set the focus of the FocusScope on export component MissingPress inherits Window {
preferred-height: 400px;
preferred-width: 400px;
background: green;
TouchArea {
fs := FocusScope {
key-pressed(event) => {
return reject;
}
}
pointer-event(event) => {
if event.kind == PointerEventKind.down {
debug("Pressed x during Press: ", self.pressed-x);
} else if event.kind == PointerEventKind.up {
debug("Pressed x during Release: ", self.pressed-x);
}
}
init => {
fs.focus();
}
}
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description
When using a component with a nested TouchArea and FocusScope the first pointer-event of the TouchArea is of type PointerEventKind.up (release). This is because the focus event captures the first event (https://github.com/slint-ui/slint/blob/master/internal/core/items/input_items.rs#L333) and it will not forwarded to the TouchArea.
On the mouse release and on the next press the FocusScope has already the focus and just ignores the event and it will be forwarded to the TouchArea
One solution I found is setting
focus-on-click: falsefor the FocusScope and setting the focus on the first click of the TouchArea. In this case the TouchArea receives all pointer-events and the FocusScope handles the key events.Is there a more elegant method?
Not working example
Working example
Beta Was this translation helpful? Give feedback.
All reactions