From 2ccc8e8baba10af2a4153ed1813e18816a7c62c1 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Wed, 25 Mar 2026 09:21:39 +0100 Subject: [PATCH] Add `Context::text_edit_focused` (#8014) --- crates/egui/src/context.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index 51a663ce5..a9151f9cd 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -1933,7 +1933,7 @@ impl Context { } } -/// Callbacks +/// Plugins impl Context { /// Call the given callback at the start of each pass of each viewport. /// @@ -2945,6 +2945,15 @@ impl Context { self.egui_wants_keyboard_input() } + /// Is the currently focused widget a text edit? + pub fn text_edit_focused(&self) -> bool { + if let Some(id) = self.memory(|mem| mem.focused()) { + crate::text_edit::TextEditState::load(self, id).is_some() + } else { + false + } + } + /// Highlight this widget, to make it look like it is hovered, even if it isn't. /// /// If you call this after the widget has been fully rendered,