Fix crash in `wants_keyboard_input`
This commit is contained in:
parent
21d045e8ef
commit
b7ec3fa1e3
|
|
@ -639,7 +639,7 @@ impl Memory {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn had_focus_last_frame(&self, id: Id) -> bool {
|
pub(crate) fn had_focus_last_frame(&self, id: Id) -> bool {
|
||||||
self.focus().id_previous_frame == Some(id)
|
self.focus().and_then(|f| f.id_previous_frame) == Some(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// True if the given widget had keyboard focus last frame, but not this one.
|
/// True if the given widget had keyboard focus last frame, but not this one.
|
||||||
|
|
@ -665,7 +665,7 @@ impl Memory {
|
||||||
|
|
||||||
/// Which widget has keyboard focus?
|
/// Which widget has keyboard focus?
|
||||||
pub fn focused(&self) -> Option<Id> {
|
pub fn focused(&self) -> Option<Id> {
|
||||||
self.focus().focused()
|
self.focus().and_then(|f| f.focused())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set an event filter for a widget.
|
/// Set an event filter for a widget.
|
||||||
|
|
@ -797,10 +797,8 @@ impl Memory {
|
||||||
self.interactions.entry(self.viewport_id).or_default()
|
self.interactions.entry(self.viewport_id).or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn focus(&self) -> &Focus {
|
pub(crate) fn focus(&self) -> Option<&Focus> {
|
||||||
self.focus
|
self.focus.get(&self.viewport_id)
|
||||||
.get(&self.viewport_id)
|
|
||||||
.expect("Failed to get focus")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn focus_mut(&mut self) -> &mut Focus {
|
pub(crate) fn focus_mut(&mut self) -> &mut Focus {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue