pub struct EventContext<C: ComponentId> {
pub focused_component: Option<C>,
pub mouse_position: Option<(u16, u16)>,
pub modifiers: KeyModifiers,
pub component_areas: HashMap<C, Rect>,
pub is_modal_open: bool,
pub active_modal: Option<C>,
}Expand description
Context passed with every event
Generic over the component ID type C which must implement ComponentId.
Fields§
§focused_component: Option<C>Currently focused component
mouse_position: Option<(u16, u16)>Current mouse position (if known)
modifiers: KeyModifiersActive key modifiers
component_areas: HashMap<C, Rect>Component areas for hit-testing
is_modal_open: boolWhether a modal is currently open
active_modal: Option<C>The active modal (if any)
Implementations§
Source§impl<C: ComponentId> EventContext<C>
impl<C: ComponentId> EventContext<C>
Sourcepub fn is_focused(&self, component: C) -> bool
pub fn is_focused(&self, component: C) -> bool
Check if a component is focused
Sourcepub fn point_in_component(&self, component: C, x: u16, y: u16) -> bool
pub fn point_in_component(&self, component: C, x: u16, y: u16) -> bool
Check if a point is within a component’s area
Sourcepub fn component_at(&self, x: u16, y: u16) -> Option<C>
pub fn component_at(&self, x: u16, y: u16) -> Option<C>
Get the component at a given point
Sourcepub fn set_component_area(&mut self, component: C, area: Rect)
pub fn set_component_area(&mut self, component: C, area: Rect)
Update the area for a component
Trait Implementations§
Source§impl<C: Clone + ComponentId> Clone for EventContext<C>
impl<C: Clone + ComponentId> Clone for EventContext<C>
Source§fn clone(&self) -> EventContext<C>
fn clone(&self) -> EventContext<C>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<C: Debug + ComponentId> Debug for EventContext<C>
impl<C: Debug + ComponentId> Debug for EventContext<C>
Source§impl<C: ComponentId> Default for EventContext<C>
impl<C: ComponentId> Default for EventContext<C>
Auto Trait Implementations§
impl<C> Freeze for EventContext<C>where
C: Freeze,
impl<C> RefUnwindSafe for EventContext<C>where
C: RefUnwindSafe,
impl<C> Send for EventContext<C>where
C: Send,
impl<C> Sync for EventContext<C>where
C: Sync,
impl<C> Unpin for EventContext<C>where
C: Unpin,
impl<C> UnwindSafe for EventContext<C>where
C: UnwindSafe,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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