Press enter in single line TextEdit
to surrender keyboard focus
This commit is contained in:
parent
796def4bcb
commit
e55b59256e
2 changed files with 9 additions and 0 deletions
|
@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
|
||||
## Unreleased
|
||||
|
||||
### Changed 🔧
|
||||
|
||||
* Pressing enter in a single-line `TextEdit` will now surrender keyboard focus for it
|
||||
|
||||
### Fixed 🐛
|
||||
|
||||
* Fixed bug where a lost widget could still retain keyboard focus.
|
||||
|
|
|
@ -169,6 +169,10 @@ impl<'t> Widget for TextEdit<'t> {
|
|||
} => {
|
||||
if multiline {
|
||||
insert_text(&mut cursor, text, "\n");
|
||||
} else {
|
||||
// Common to end input with enter
|
||||
ui.memory().surrender_kb_focus(id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
Event::Key {
|
||||
|
@ -176,6 +180,7 @@ impl<'t> Widget for TextEdit<'t> {
|
|||
pressed: true,
|
||||
} => {
|
||||
ui.memory().surrender_kb_focus(id);
|
||||
break;
|
||||
}
|
||||
Event::Key { key, pressed: true } => {
|
||||
on_key_press(&mut cursor, text, *key);
|
||||
|
|
Loading…
Reference in a new issue