diff --git a/CHANGELOG.md b/CHANGELOG.md index d65e6188..5b22ad94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## Unreleased +### Fixed 🐛 + +* Fixed bug where a lost widget could still retain keyboard focus. + ## 0.3.0 - 2020-11-07 ### Added ⭐ diff --git a/egui/src/memory.rs b/egui/src/memory.rs index 80bac45f..c4177c6f 100644 --- a/egui/src/memory.rs +++ b/egui/src/memory.rs @@ -130,6 +130,13 @@ impl Memory { pub(crate) fn end_frame(&mut self) { self.areas.end_frame(); + + if let Some(kb_focus_id) = self.interaction.kb_focus_id { + if !self.used_ids.contains_key(&kb_focus_id) { + // Dead-mans-switch: the widget with kb focus has dissappeared! + self.interaction.kb_focus_id = None; + } + } } pub fn layer_id_at(&self, pos: Pos2, resize_interact_radius_side: f32) -> Option {