[][src]Struct druid::EventCtx

pub struct EventCtx<'a, D: Data + 'static + Default> {
    win_ctx: &'a mut dyn WinCtx,
    window_id: WindowId,
    window: &'a WindowHandle<DruidHandler<D>>,
    base_state: &'a mut BaseState,
    had_active: bool,
    is_handled: bool,
    is_root: bool,
}

A mutable context provided to event handling methods of widgets.

Widgets should call invalidate whenever an event causes a change in the widget's appearance, to schedule a repaint.

Fields

win_ctx: &'a mut dyn WinCtxwindow_id: WindowId

Commands submitted to be run after this event.

window: &'a WindowHandle<DruidHandler<D>>base_state: &'a mut BaseStatehad_active: boolis_handled: boolis_root: bool

Methods

impl<'a, D: Data + 'static + Default> EventCtx<'a, D>[src]

pub fn invalidate(&mut self)[src]

Invalidate.

Right now, it just invalidates the entire window, but we'll want finer grained invalidation before long.

pub fn text(&mut self) -> &mut Text[src]

Get an object which can create text layouts.

pub fn set_active(&mut self, active: bool)[src]

Set the "active" state of the widget.

See BaseState::is_active.

pub fn is_hot(&self) -> bool[src]

Query the "hot" state of the widget.

See BaseState::is_hot.

pub fn is_active(&self) -> bool[src]

Query the "active" state of the widget.

This is the same state set by set_active and is provided as a convenience.

pub fn window(&self) -> &WindowHandle<DruidHandler<D>>[src]

Returns a reference to the current WindowHandle.

Note: we're in the process of migrating towards providing functionality provided by the window handle in mutable contexts instead. If you're considering a new use of this method, try adding it to WinCtx and plumbing it through instead.

pub fn set_handled(&mut self)[src]

Set the event as "handled", which stops its propagation to other widgets.

pub fn is_handled(&self) -> bool[src]

Determine whether the event has been handled by some other widget.

pub fn has_focus(&self) -> bool[src]

Query the focus state of the widget.

See BaseState::has_focus.

pub fn request_focus(&mut self)[src]

Request keyboard focus.

Discussion question: is method needed in contexts other than event?

pub fn size(&self) -> Size[src]

Returns the layout size of the current widget.

pub fn window_id(&self) -> WindowId[src]

Get the window id.

Auto Trait Implementations

impl<'a, D> !Send for EventCtx<'a, D>

impl<'a, D> !Sync for EventCtx<'a, D>

impl<'a, D> Unpin for EventCtx<'a, D>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> RoundFrom<T> for T[src]

impl<T, U> RoundInto<U> for T where
    U: RoundFrom<T>, 
[src]

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.