Struct rat_focus::event::util::MouseFlags
source · pub struct MouseFlags {
pub click: Cell<bool>,
pub clack: Cell<bool>,
pub drag: Cell<bool>,
}Expand description
Some state for mouse interactions.
This helps with double-click and mouse drag recognition. Add this to your widget state.
Fields§
§click: Cell<bool>Flag for the first down.
clack: Cell<bool>Flag for the first up.
drag: Cell<bool>Drag enabled.
Implementations§
source§impl MouseFlags
impl MouseFlags
sourcepub fn pos_of(&self, event: &MouseEvent) -> (u16, u16)
pub fn pos_of(&self, event: &MouseEvent) -> (u16, u16)
Returns the last drag-position if drag is active.
sourcepub fn drag(&self, area: Rect, event: &MouseEvent) -> bool
pub fn drag(&self, area: Rect, event: &MouseEvent) -> bool
Checks if this is a drag event for the widget.
It makes sense to allow drag events outside the given area, if the drag has been started with a click to the given area.
This function handles that case.
sourcepub fn drag2(
&self,
area: Rect,
event: &MouseEvent,
filter: KeyModifiers,
) -> bool
pub fn drag2( &self, area: Rect, event: &MouseEvent, filter: KeyModifiers, ) -> bool
Checks if this is a drag event for the widget.
It makes sense to allow drag events outside the given area, if the drag has been started with a click to the given area.
This function handles that case.
sourcepub fn doubleclick(&self, area: Rect, event: &MouseEvent) -> bool
pub fn doubleclick(&self, area: Rect, event: &MouseEvent) -> bool
Checks for double-click events.
This can be integrated in the event-match with a guard:
match event {
Event::Mouse(m) if state.mouse.doubleclick(state.area, m) => {
state.flip = !state.flip;
Outcome::Changed
}
}sourcepub fn doubleclick2(
&self,
area: Rect,
event: &MouseEvent,
filter: KeyModifiers,
) -> bool
pub fn doubleclick2( &self, area: Rect, event: &MouseEvent, filter: KeyModifiers, ) -> bool
Checks for double-click events. This one can have an extra KeyModifiers.
This can be integrated in the event-match with a guard:
match event {
Event::Mouse(m) if state.mouse.doubleclick(state.area, m) => {
state.flip = !state.flip;
Outcome::Changed
}
}Trait Implementations§
source§impl Clone for MouseFlags
impl Clone for MouseFlags
source§fn clone(&self) -> MouseFlags
fn clone(&self) -> MouseFlags
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for MouseFlags
impl Debug for MouseFlags
source§impl Default for MouseFlags
impl Default for MouseFlags
source§fn default() -> MouseFlags
fn default() -> MouseFlags
source§impl PartialEq for MouseFlags
impl PartialEq for MouseFlags
source§fn eq(&self, other: &MouseFlags) -> bool
fn eq(&self, other: &MouseFlags) -> bool
self and other values to be equal, and is used
by ==.impl Eq for MouseFlags
impl StructuralPartialEq for MouseFlags
Auto Trait Implementations§
impl !Freeze for MouseFlags
impl !RefUnwindSafe for MouseFlags
impl Send for MouseFlags
impl !Sync for MouseFlags
impl Unpin for MouseFlags
impl UnwindSafe for MouseFlags
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more