Add Response::has_kb_focus()

Closes https://github.com/emilk/egui/issues/196
This commit is contained in:
Emil Ernerfeldt 2021-02-28 18:19:33 +01:00
parent 834078a476
commit 8be37b3d6c

View file

@ -60,7 +60,7 @@ pub struct Response {
/// `None` if the widget is not being interacted with.
pub(crate) interact_pointer_pos: Option<Pos2>,
/// 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,