Let go of the keyboard when a name is finished
Pressing Enter on a person's name committed it and then kept the field focused, so on a tablet the on-screen keyboard stayed up over the faces the user had pressed Enter to get back to. The name looked accepted and the screen looked stuck. `Field` grows `release-focus()`, the other half of the `take-focus()` it already had, and the Identity screen calls it from `accepted`. A function rather than a property for the reason the existing one gives: focus is an event, and bound to a property it would fight anything else that took it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -433,7 +433,16 @@ export component IdentityScreen inherits Rectangle {
|
||||
: 0px;
|
||||
visible: root.selected-person >= 0;
|
||||
edited(t) => { root.name-edited(t); }
|
||||
accepted(t) => { root.rename(t); }
|
||||
// Enter *finishes* naming this person, so the field lets
|
||||
// the keyboard go with it. Without this the entry keeps
|
||||
// focus after the name is committed, and on a tablet the
|
||||
// on-screen keyboard stays up over the faces the user
|
||||
// pressed Enter to get back to — the name looks accepted
|
||||
// and the screen looks stuck.
|
||||
accepted(t) => {
|
||||
root.rename(t);
|
||||
name-field.release-focus();
|
||||
}
|
||||
}
|
||||
if root.selected-person < 0: Text {
|
||||
text: "Select a person";
|
||||
|
||||
@@ -632,6 +632,19 @@ export component Field inherits Rectangle {
|
||||
input.select-all();
|
||||
}
|
||||
|
||||
/// Give the keyboard back.
|
||||
///
|
||||
/// The other half of `take-focus`, and the one a field that *submits*
|
||||
/// needs: pressing Enter on a name has finished with the name, but Slint
|
||||
/// leaves the entry focused, so on a tablet the on-screen keyboard stays
|
||||
/// up covering the very thing the user just named. Nothing else on those
|
||||
/// screens takes focus on its own, so the field has to let go itself.
|
||||
///
|
||||
/// A function and not a property, for the reason `take-focus` gives.
|
||||
public function release-focus() {
|
||||
input.clear-focus();
|
||||
}
|
||||
|
||||
height: Theme.touch-target;
|
||||
border-radius: Theme.radius;
|
||||
border-width: 1px;
|
||||
|
||||
Reference in New Issue
Block a user