pub struct EventCtx { /* private fields */ }Implementations§
Source§impl EventCtx
impl EventCtx
pub const fn window_id(&self) -> WindowId
pub const fn widget_id(&self) -> WidgetId
Sourcepub fn observe<T, O>(&self, observable: &O, kind: InvalidationKind) -> Twhere
O: Observable<T> + ?Sized,
pub fn observe<T, O>(&self, observable: &O, kind: InvalidationKind) -> Twhere
O: Observable<T> + ?Sized,
Read an observable and subscribe this widget to the requested invalidation kind.
Sourcepub fn record_rebuild(
&self,
widget_name: &'static str,
reason: impl Into<String>,
)
pub fn record_rebuild( &self, widget_name: &'static str, reason: impl Into<String>, )
Record a development diagnostic explaining a structural widget rebuild.
pub const fn bounds(&self) -> Rect
pub const fn dpi(&self) -> DpiInfo
pub const fn current_time(&self) -> f64
Sourcepub fn motion_policy(&self) -> MotionPolicy
pub fn motion_policy(&self) -> MotionPolicy
The motion policy that transitions started now should follow.
Sourcepub fn animate<T>(
&mut self,
motion: &mut Motion<T>,
target: T,
spec: AnimationSpec,
) -> bool
pub fn animate<T>( &mut self, motion: &mut Motion<T>, target: T, spec: AnimationSpec, ) -> bool
Animate motion toward target with spec, under the motion
policy. The runtime invalidates this widget (with the motion’s
invalidation kind) every frame until the transition ends; read the
value with motion.get(ctx). Returns whether a transition started.
Sourcepub fn animate_after<T>(
&mut self,
motion: &mut Motion<T>,
target: T,
delay: f64,
spec: AnimationSpec,
) -> bool
pub fn animate_after<T>( &mut self, motion: &mut Motion<T>, target: T, delay: f64, spec: AnimationSpec, ) -> bool
Like animate, starting delay seconds from now. Use a
Stagger to start a group of transitions one
after another.
Sourcepub fn track_motion(&mut self, until: f64, kind: InvalidationKind)
pub fn track_motion(&mut self, until: f64, kind: InvalidationKind)
Keep invalidating this widget with kind every animation frame until
until (in frame time), for presentation that is a function of time.
Sourcepub fn track_motion_for(
&mut self,
target: WidgetId,
until: f64,
kind: InvalidationKind,
)
pub fn track_motion_for( &mut self, target: WidgetId, until: f64, kind: InvalidationKind, )
Like track_motion, for another widget: a container animating a
child’s layer keeps the child’s layer updated until until.
Sourcepub fn track_motion_end(&mut self, until: f64, kind: InvalidationKind)
pub fn track_motion_end(&mut self, until: f64, kind: InvalidationKind)
Invalidate this widget with kind once, at the first frame at or
after until: for state that changes when a motion ends, such as
content that stops taking space once it has faded out.
Sourcepub fn track_motion_end_for(
&mut self,
target: WidgetId,
until: f64,
kind: InvalidationKind,
)
pub fn track_motion_end_for( &mut self, target: WidgetId, until: f64, kind: InvalidationKind, )
Like track_motion_end, for another widget.
pub const fn phase(&self) -> EventPhase
pub const fn focused_widget_id(&self) -> Option<WidgetId>
pub fn is_focused(&self) -> bool
pub const fn is_handled(&self) -> bool
pub fn set_handled(&mut self)
Sourcepub fn clipboard(&self) -> &Clipboard
pub fn clipboard(&self) -> &Clipboard
Shared clipboard service for this window. Backed by the OS clipboard when the platform installed a native backend, otherwise by in-process storage shared across the runtime.
pub fn clipboard_text(&self) -> Option<String>
pub fn set_clipboard_text(&mut self, text: impl AsRef<str>)
Sourcepub fn command_sender(&self) -> &CommandSender
pub fn command_sender(&self) -> &CommandSender
Return the runtime’s cloneable typed command producer.
Widget callbacks can use this to address window or application controllers without routing through an ancestor widget. Delivery is queued until the current event dispatch completes.
Sourcepub fn post_event(&mut self, target: WidgetId, event: Event)
pub fn post_event(&mut self, target: WidgetId, event: Event)
Queue an event for delivery to target after the current dispatch
completes. Used to route commands (for example clipboard actions from
a context menu) to a specific widget outside the normal hit-test or
focus routing.
Sourcepub fn post_command<T>(
&mut self,
target: WidgetId,
key: CommandKey<T>,
payload: T,
)
pub fn post_command<T>( &mut self, target: WidgetId, key: CommandKey<T>, payload: T, )
Queue a typed command for target-only delivery after the current widget dispatch completes.
pub fn request_focus(&mut self)
Sourcepub fn request_focus_for(&mut self, widget_id: WidgetId)
pub fn request_focus_for(&mut self, widget_id: WidgetId)
Request focus for a retained widget in the current window.
Containers use this to restore focus to a descendant after adaptive presentation changes. The target must be mounted in the widget graph by the time the current event dispatch completes.
pub fn clear_focus(&mut self)
Sourcepub fn keep_focus(&mut self)
pub fn keep_focus(&mut self)
Leave focus where it is. A pointer press otherwise focuses the widget pressed, or clears focus when it cannot take it; a toolbar button that acts on an editor keeps the editor focused this way. Tab and assistive technology still focus the widget as usual.
pub fn schedule_timer_at(&mut self, deadline: f64) -> TimerToken
pub fn schedule_timer_after(&mut self, delay: f64) -> TimerToken
pub fn cancel_timer(&mut self, token: TimerToken)
pub fn register_async_wakeup(&mut self) -> AsyncWakeToken
pub fn unregister_async_wakeup(&mut self, token: AsyncWakeToken)
pub fn request_animation_frame(&mut self)
pub fn request_pointer_capture(&mut self, pointer_id: u64)
pub fn release_pointer_capture(&mut self, pointer_id: u64)
Sourcepub fn request_cursor_grab(&mut self, mode: CursorGrabMode)
pub fn request_cursor_grab(&mut self, mode: CursorGrabMode)
Request host-level cursor grabbing for this widget.
The request is best effort. Desktop hosts try CursorGrabMode::Locked
first and then fall back to CursorGrabMode::Confined. Relative mouse
motion is routed to this widget while a grab is active. Request
CursorGrabMode::None to release a grab owned by this widget.
Sourcepub fn request_cursor_visibility(&mut self, visible: bool)
pub fn request_cursor_visibility(&mut self, visible: bool)
Request whether the host system cursor is visible for this widget.
Cursor visibility is independent of cursor grabbing. Focus loss always restores visibility.
Sourcepub fn begin_drag(
&mut self,
scope_id: DragScopeId,
pointer_id: u64,
position: Point,
payload: DragPayload,
allowed_effects: impl Into<DropEffects>,
preview_label: Option<String>,
) -> DragSessionId
pub fn begin_drag( &mut self, scope_id: DragScopeId, pointer_id: u64, position: Point, payload: DragPayload, allowed_effects: impl Into<DropEffects>, preview_label: Option<String>, ) -> DragSessionId
Start a drag of payload with the pointer pointer_id. The source
allows allowed_effects: a single DropEffect or a
DropEffects set, whose DropEffects::default_effect applies
when no modifier key asks for another.
Sourcepub fn refresh_drag_targets(&mut self)
pub fn refresh_drag_targets(&mut self)
Ask the runtime to work out again which drop targets an active drag is over, as content moved under a pointer that did not. Scroll views call this when they scroll during a drag.