Skip to main content

EventCx

Struct EventCx 

Source
pub struct EventCx<'a, Msg> { /* private fields */ }
Expand description

Event handling context.

Implementations§

Source§

impl<Msg> EventCx<'_, Msg>

Source

pub fn id(&self) -> WidgetId

The id of the widget handling the event.

Source

pub fn area(&self) -> Rect

The area the widget was painted in during the last frame.

Source

pub fn focused_area(&self) -> Option<Rect>

The area the focused widget was painted in during the last frame, if a widget has focus. Lets a container place something next to the focused child, e.g. a context menu opened from the keyboard.

Source

pub fn env(&self) -> &Env

The environment.

Source

pub fn now(&self) -> Duration

Time since the runtime started.

Source

pub fn emit(&mut self, message: Msg)

Sends a message to the application.

Source

pub fn memory<T: Default + 'static>(&mut self) -> &mut T

This widget’s state of type T.

Source

pub fn is_focused(&self) -> bool

Whether this widget has keyboard focus.

Source

pub fn request_focus(&mut self)

Moves keyboard focus to this widget.

Source

pub fn focus_next(&mut self)

Moves keyboard focus to the next widget in focus order, as Tab does. Forms use it to go to the next field on Enter.

Source

pub fn forward(&mut self, node: &Node<Msg>, rect: Rect, event: &Event) -> bool
where Msg: 'static,

Offers event to a child node painted in rect, as if the child had received it: the child keeps its own memory, and its messages and requests go out with this widget’s. For widgets that take focus as one control and let a child act, e.g. a settings row passing Space to its switch. Returns whether the child used the event.

Source

pub fn capture_keys(&mut self, on: bool)

While on, every key event goes to this widget first (an open dropdown), and a pointer press on any other widget, including one inside it, first sends it Event::PointerOutside and then reaches that widget as usual. A press on this widget itself reaches only this widget.

Source

pub fn capture_pointer(&mut self)

Keeps pointer events flowing to this widget until the button is released.

Source

pub fn flash(&mut self)

Flashes this widget to confirm an activation.

Source

pub fn copy(&mut self, text: impl Into<String>)

Copies text to the system clipboard.

Source

pub fn run_action(&mut self, scope: Scope, action: impl Into<String>)

Runs keymap action action of scope as if its key had been pressed, after this event. Application actions reach App::action even while a modal layer is open, since the user asked for them explicitly (e.g. from a command palette).

Source

pub fn repeat_pointer(&mut self, interval: Duration)

While the pointer is captured, delivers a Drag event at the last pointer position to this widget every interval until the button is released, as if the pointer moved in place. Terminals send nothing while a button is held still; this lets a widget react to how long it is held (hold-to-confirm, auto-repeating steppers). Call it together with EventCx::capture_pointer on the button press.

Source

pub fn stop_pointer_repeat(&mut self)

Ends the repeat EventCx::repeat_pointer started for this widget before the button is released, so a widget that needs timed drags only for a while (scrolling while a dragged item rests against an edge) does not keep waking the loop afterwards. A repeat asked for in the same event wins. Nothing happens when this widget has no repeat running.

Auto Trait Implementations§

§

impl<'a, Msg> !RefUnwindSafe for EventCx<'a, Msg>

§

impl<'a, Msg> !Send for EventCx<'a, Msg>

§

impl<'a, Msg> !Sync for EventCx<'a, Msg>

§

impl<'a, Msg> !UnwindSafe for EventCx<'a, Msg>

§

impl<'a, Msg> Freeze for EventCx<'a, Msg>
where &'a mut Vec<Msg>: Freeze,

§

impl<'a, Msg> Unpin for EventCx<'a, Msg>
where &'a mut Vec<Msg>: Unpin,

§

impl<'a, Msg> UnsafeUnpin for EventCx<'a, Msg>
where &'a mut Vec<Msg>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.