Add fn Memory::gained_kb_focus() -> bool
query
This commit is contained in:
parent
007f9f3cb9
commit
5d0c71350d
1 changed files with 10 additions and 1 deletions
|
@ -207,9 +207,18 @@ impl Memory {
|
||||||
self.areas.layer_id_at(pos, resize_interact_radius_side)
|
self.areas.layer_id_at(pos, resize_interact_radius_side)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn had_kb_focus_last_frame(&self, id: Id) -> bool {
|
||||||
|
self.interaction.kb_focus_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.
|
||||||
pub fn lost_kb_focus(&self, id: Id) -> bool {
|
pub fn lost_kb_focus(&self, id: Id) -> bool {
|
||||||
self.interaction.kb_focus_id_previous_frame == Some(id) && !self.has_kb_focus(id)
|
self.had_kb_focus_last_frame(id) && !self.has_kb_focus(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// True if the given widget has keyboard focus this frame, but didn't last frame.
|
||||||
|
pub fn gained_kb_focus(&self, id: Id) -> bool {
|
||||||
|
!self.had_kb_focus_last_frame(id) && self.has_kb_focus(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_kb_focus(&self, id: Id) -> bool {
|
pub fn has_kb_focus(&self, id: Id) -> bool {
|
||||||
|
|
Loading…
Reference in a new issue