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