From 8be37b3d6ce02aff62c8d6e63614736df076d1d6 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sun, 28 Feb 2021 18:19:33 +0100 Subject: [PATCH] Add Response::has_kb_focus() Closes https://github.com/emilk/egui/issues/196 --- egui/src/response.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/egui/src/response.rs b/egui/src/response.rs index f1965eeb..1a0bd560 100644 --- a/egui/src/response.rs +++ b/egui/src/response.rs @@ -60,7 +60,7 @@ pub struct Response { /// `None` if the widget is not being interacted with. pub(crate) interact_pointer_pos: Option, - /// This widget has the keyboard focus (i.e. is receiving key pressed). + /// This widget has the keyboard focus (i.e. is receiving key presses). pub(crate) has_kb_focus: bool, /// The widget had keyboard focus and lost it. @@ -145,6 +145,11 @@ impl Response { self.hovered } + /// This widget has the keyboard focus (i.e. is receiving key presses). + pub fn has_kb_focus(&self) -> bool { + self.has_kb_focus + } + /// The widget had keyboard focus and lost it, /// perhaps because the user pressed enter. /// If you want to do an action when a user presses enter in a text field,