Add Event::grabs_focus

This commit is contained in:
Alexandre Bury 2017-10-11 15:06:35 -07:00
parent f02dda5a0a
commit 0bb1fb4b2a

View File

@ -243,6 +243,18 @@ impl MouseEvent {
_ => None,
}
}
/// Returns `true` if `self` is an event that can grab focus.
///
/// This includes `Press`, `WheelUp` and `WheelDown`.
pub fn grabs_focus(self) -> bool {
match self {
MouseEvent::Press(_) |
MouseEvent::WheelUp |
MouseEvent::WheelDown => true,
_ => false,
}
}
}
/// Represents an event as seen by the application.