mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 13:20:05 -04:00
Press enter in single line TextEdit to surrender keyboard focus
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user