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
|
## Unreleased
|
||||||
|
|
||||||
|
### Changed 🔧
|
||||||
|
|
||||||
|
* Pressing enter in a single-line `TextEdit` will now surrender keyboard focus for it
|
||||||
|
|
||||||
### Fixed 🐛
|
### Fixed 🐛
|
||||||
|
|
||||||
* Fixed bug where a lost widget could still retain keyboard focus.
|
* Fixed bug where a lost widget could still retain keyboard focus.
|
||||||
|
|
|
@ -169,6 +169,10 @@ impl<'t> Widget for TextEdit<'t> {
|
||||||
} => {
|
} => {
|
||||||
if multiline {
|
if multiline {
|
||||||
insert_text(&mut cursor, text, "\n");
|
insert_text(&mut cursor, text, "\n");
|
||||||
|
} else {
|
||||||
|
// Common to end input with enter
|
||||||
|
ui.memory().surrender_kb_focus(id);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event::Key {
|
Event::Key {
|
||||||
|
@ -176,6 +180,7 @@ impl<'t> Widget for TextEdit<'t> {
|
||||||
pressed: true,
|
pressed: true,
|
||||||
} => {
|
} => {
|
||||||
ui.memory().surrender_kb_focus(id);
|
ui.memory().surrender_kb_focus(id);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
Event::Key { key, pressed: true } => {
|
Event::Key { key, pressed: true } => {
|
||||||
on_key_press(&mut cursor, text, *key);
|
on_key_press(&mut cursor, text, *key);
|
||||||
|
|
Loading…
Reference in a new issue