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<'_>
impl EventCx<'_>
Sourcepub fn rect(&self) -> Rect
pub fn rect(&self) -> Rect
Where the widget is, in physical pixels from the window’s top-left corner.
Sourcepub fn content_rect(&self) -> Rect
pub fn content_rect(&self) -> Rect
The widget’s rectangle inside its padding.
Sourcepub fn content_size(&self) -> Size
pub fn content_size(&self) -> Size
The size of what the widget’s children cover.
Sourcepub fn is_hovered(&self) -> bool
pub fn is_hovered(&self) -> bool
Whether the pointer is over the widget or one of its children.
Sourcepub fn is_focused(&self) -> bool
pub fn is_focused(&self) -> bool
Whether the widget has keyboard focus.
Sourcepub fn is_pressed(&self) -> bool
pub fn is_pressed(&self) -> bool
Whether the widget handled a pointer press that has not been released yet.
Sourcepub fn text_system(&mut self) -> &mut TextSystem
pub fn text_system(&mut self) -> &mut TextSystem
The text system, to edit and re-lay out text.
Sourcepub fn request_paint(&mut self)
pub fn request_paint(&mut self)
Asks for the next frame to be painted.
Sourcepub fn request_layout(&mut self)
pub fn request_layout(&mut self)
Asks for the widget to be measured again: its content changed size.
Sourcepub fn request_focus(&mut self)
pub fn request_focus(&mut self)
Asks for keyboard focus, given once the event has been handled.
Sourcepub fn release_focus(&mut self)
pub fn release_focus(&mut self)
Gives keyboard focus up, if the widget has it.
Sourcepub fn release_pointer(&mut self)
pub fn release_pointer(&mut self)
Stops receiving the pointer’s moves and release after a press.
Sourcepub fn set_cursor(&mut self, cursor: Option<Cursor>)
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.
Sourcepub fn set_ime_area(&mut self, area: Option<Rect>)
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.
Sourcepub fn emit(&mut self, kind: ActionKind)
pub fn emit(&mut self, kind: ActionKind)
Reports kind to the application.
Sourcepub fn scroll_to(&mut self, offset: Point) -> Point
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.
Sourcepub fn focus_within(&self, id: WidgetId) -> bool
pub fn focus_within(&self, id: WidgetId) -> bool
Whether keyboard focus is on id or a widget inside it.
Source§impl EventCx<'_>
impl EventCx<'_>
Sourcepub fn open_popup(
&mut self,
widget: impl Widget,
anchor: Anchor,
style: Style,
) -> Result<WidgetId, UiError>
pub fn open_popup( &mut self, widget: impl Widget, anchor: Anchor, style: Style, ) -> Result<WidgetId, UiError>
Opens widget as a popup next to anchor, as Ui::open_popup does, with this
widget as its opener: a press on this widget while the popup is open closes the
popup and still reaches this widget. The popup joins the Ui once the event is
handled.
§Errors
Sourcepub fn close_popup(&mut self, id: WidgetId) -> bool
pub fn close_popup(&mut self, id: WidgetId) -> bool
Closes popup id (this widget, say) and every popup opened after it, once the event
is handled. false if id is not open.
Sourcepub fn close_popups(&mut self)
pub fn close_popups(&mut self)
Closes every popup once the event is handled (a menu item was chosen).
Sourcepub fn is_popup_open(&self, id: WidgetId) -> bool
pub fn is_popup_open(&self, id: WidgetId) -> bool
Whether id is an open popup.