Skip to main content

WidgetEvent

Enum WidgetEvent 

Source
pub enum WidgetEvent {
Show 15 variants PointerDown { position: Point, button: PointerButton, modifiers: Modifiers, }, PointerUp { position: Point, button: PointerButton, modifiers: Modifiers, }, PointerMove { position: Point, }, PointerEnter, PointerLeave, Scroll { delta: ScrollDelta, modifiers: Modifiers, }, KeyDown { key: Key, modifiers: Modifiers, text: Option<String>, }, KeyUp { key: Key, modifiers: Modifiers, }, ImeComposition { text: String, cursor: Option<Range<usize>>, }, ImeCommit { text: String, }, FocusGained { origin: FocusOrigin, }, FocusLost, AccessAction { action: Action, target: Option<WidgetId>, target_node: NodeId, data: Option<ActionData>, }, ScrollIntoView { target_bounds: Rect, margin: f32, align: ScrollAlign, motion: ScrollMotion, applied_scroll: Option<Arc<Mutex<Point>>>, }, Gesture { gesture: GestureEvent, },
}
Expand description

Events dispatched to widgets.

Variants§

§

PointerDown

Fields

§position: Point
§modifiers: Modifiers
§

PointerUp

Fields

§position: Point
§modifiers: Modifiers
§

PointerMove

Fields

§position: Point
§

PointerEnter

§

PointerLeave

§

Scroll

Fields

§modifiers: Modifiers

Modifier keys held at the time of the scroll event. Defaults to Modifiers::NONE for synthesized events (tests, keyboard-driven scroll requests). Real-platform scroll events populate this from the platform’s tracked modifier state — apps detect Ctrl-wheel-to-zoom by inspecting modifiers.ctrl().

§

KeyDown

Fields

§key: Key
§modifiers: Modifiers
§

KeyUp

Fields

§key: Key
§modifiers: Modifiers
§

ImeComposition

Fields

§text: String
§cursor: Option<Range<usize>>
§

ImeCommit

Fields

§text: String
§

FocusGained

Fields

§

FocusLost

§

AccessAction

Fields

§action: Action
§target_node: NodeId

Raw AccessKit NodeId from the original ActionRequest. May be a synthetic (widget-emitted child) NodeId — use crate::accessibility::is_synthetic to distinguish it from a widget-derived NodeId. The widget that registered the parent (retrieved via tree.widget_for_synthetic) is the one set in target.

§data: Option<ActionData>

Payload carried by the ActionRequest. For Action::SetTextSelection this is ActionData::SetTextSelection(TextSelection), for Action::SetValue it’s ActionData::Value(Box<str>), for scroll actions it carries scroll offsets, etc. Widgets that declare these actions must read the payload to honour screen-reader-initiated requests.

§

ScrollIntoView

Dispatched by the framework to a clipping ancestor when a child gains focus but is outside the viewport. The scroll area adjusts its offset to make the target bounds visible, with an optional margin around the target.

Fields

§target_bounds: Rect
§margin: f32

Extra margin (in logical pixels) to keep around the target when scrolling it into view. Defaults to 0.0.

§align: ScrollAlign

Where the target should end up on the scroll container’s vertical axis. ScrollAlign::Minimal (the default, and what every focus-driven reveal uses) only scrolls when the target is not already fully visible; ScrollAlign::Fraction pins it to a fixed height in the viewport whether or not it was already visible.

§motion: ScrollMotion

Whether the container should jump to the new offset or glide to it. See ScrollMotion.

§applied_scroll: Option<Arc<Mutex<Point>>>

Optional back-channel for the handling scroll container to report how far it actually scrolled ((dx, dy) in content pixels). When several nested scroll containers must each reveal the same target, the ancestor walk (scroll_rect_into_view) reads this after dispatching to an inner container and shifts target_bounds by the negated delta before asking the next (outer) one — so the outer sees where the target will land once the inner’s (deferred) scroll applies, not its pre-scroll position. None disables reporting (the nested-reveal refinement is unavailable). A handler that ignores it still works for the common single-container case.

Arc<Mutex<..>> (not Rc<Cell<..>>) so WidgetEvent stays Send — some events are posted across threads. This one is only ever touched on the dispatch thread, so the lock is always uncontended.

§

Gesture

A recognized gesture event, routed through the same preview/bubble system.

Fields

Trait Implementations§

Source§

impl Clone for WidgetEvent

Source§

fn clone(&self) -> WidgetEvent

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WidgetEvent

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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, <T as TryFrom<U>>::Error>

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.