Skip to main content

EventCx

Struct EventCx 

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

What a widget gets while it handles an event (or is updated by the application through Ui::update): its state, and requests to the Ui.

Implementations§

Source§

impl EventCx<'_>

Source

pub fn id(&self) -> WidgetId

The widget handling the event.

Source

pub fn rect(&self) -> Rect

Where the widget is, in physical pixels from the window’s top-left corner.

Source

pub fn content_rect(&self) -> Rect

The widget’s rectangle inside its padding.

Source

pub fn scroll(&self) -> Point

How far the widget’s children are scrolled.

Source

pub fn content_size(&self) -> Size

The size of what the widget’s children cover.

Source

pub fn is_hovered(&self) -> bool

Whether the pointer is over the widget or one of its children.

Source

pub fn is_focused(&self) -> bool

Whether the widget has keyboard focus.

Source

pub fn is_pressed(&self) -> bool

Whether the widget handled a pointer press that has not been released yet.

Source

pub fn theme(&self) -> &Theme

The theme.

Source

pub fn scale(&self) -> f32

Physical pixels per logical pixel.

Source

pub fn px(&self, logical: f32) -> f32

logical pixels in physical pixels.

Source

pub fn text_system(&mut self) -> &mut TextSystem

The text system, to edit and re-lay out text.

Source

pub fn request_paint(&mut self)

Asks for the next frame to be painted.

Source

pub fn request_layout(&mut self)

Asks for the widget to be measured again: its content changed size.

Source

pub fn request_focus(&mut self)

Asks for keyboard focus, given once the event has been handled.

Source

pub fn release_focus(&mut self)

Gives keyboard focus up, if the widget has it.

Source

pub fn release_pointer(&mut self)

Stops receiving the pointer’s moves and release after a press.

Source

pub fn set_cursor(&mut self, cursor: Option<Cursor>)

The cursor shown over the widget (and its children that set none); None for its parent’s.

Source

pub fn set_ime_area(&mut self, area: Option<Rect>)

Where an input method should show its candidates while the widget has focus: the caret’s rectangle.

Source

pub fn emit(&mut self, kind: ActionKind)

Reports kind to the application.

Source

pub fn scroll_to(&mut self, offset: Point) -> Point

Scrolls the widget’s children by offset from their laid-out place, clamped so the content stays in view. Returns the offset applied.

Source

pub fn children(&self) -> &[WidgetId]

The widget’s children, first painted first.

Source

pub fn rect_of(&self, id: WidgetId) -> Option<Rect>

Where id is, if it is alive.

Source

pub fn style_of(&self, id: WidgetId) -> Option<&Style>

The style of id, if it is alive.

Source

pub fn focus_within(&self, id: WidgetId) -> bool

Whether keyboard focus is on id or a widget inside it.

Source

pub fn set_style(&mut self, id: WidgetId, style: Style) -> bool

Changes the style of the widget itself or of a widget inside it (a splitter resizing its panes, tabs showing one page); false for any other widget.

Trait Implementations§

Source§

impl<'a> Debug for EventCx<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<'a> Freeze for EventCx<'a>

§

impl<'a> Unpin for EventCx<'a>

§

impl<'a> UnsafeUnpin for EventCx<'a>

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> ErasedDestructor for T
where T: 'static,

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, 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.