Skip to main content

EventHandlersExt

Trait EventHandlersExt 

Source
pub trait EventHandlersExt: Sized {
Show 35 methods // Required method fn get_event_handlers( &mut self, ) -> &mut FxHashMap<EventName, EventHandlerType>; // Provided methods fn with_event_handlers( self, event_handlers: FxHashMap<EventName, EventHandlerType>, ) -> Self { ... } fn on_mouse_down( self, on_mouse_down: impl Into<EventHandler<Event<MouseEventData>>>, ) -> Self { ... } fn on_mouse_up( self, on_mouse_up: impl Into<EventHandler<Event<MouseEventData>>>, ) -> Self { ... } fn on_mouse_move( self, on_mouse_move: impl Into<EventHandler<Event<MouseEventData>>>, ) -> Self { ... } fn on_global_pointer_press( self, on_global_pointer_press: impl Into<EventHandler<Event<PointerEventData>>>, ) -> Self { ... } fn on_global_pointer_down( self, on_global_pointer_down: impl Into<EventHandler<Event<PointerEventData>>>, ) -> Self { ... } fn on_global_pointer_move( self, on_global_pointer_move: impl Into<EventHandler<Event<PointerEventData>>>, ) -> Self { ... } fn on_capture_global_pointer_move( self, on_capture_global_pointer_move: impl Into<EventHandler<Event<PointerEventData>>>, ) -> Self { ... } fn on_capture_global_pointer_press( self, on_capture_global_pointer_press: impl Into<EventHandler<Event<PointerEventData>>>, ) -> Self { ... } fn on_key_down( self, on_key_down: impl Into<EventHandler<Event<KeyboardEventData>>>, ) -> Self { ... } fn on_key_up( self, on_key_up: impl Into<EventHandler<Event<KeyboardEventData>>>, ) -> Self { ... } fn on_global_key_down( self, on_global_key_down: impl Into<EventHandler<Event<KeyboardEventData>>>, ) -> Self { ... } fn on_global_key_up( self, on_global_key_up: impl Into<EventHandler<Event<KeyboardEventData>>>, ) -> Self { ... } fn on_wheel( self, on_wheel: impl Into<EventHandler<Event<WheelEventData>>>, ) -> Self { ... } fn on_touch_cancel( self, on_touch_cancel: impl Into<EventHandler<Event<TouchEventData>>>, ) -> Self { ... } fn on_touch_start( self, on_touch_start: impl Into<EventHandler<Event<TouchEventData>>>, ) -> Self { ... } fn on_touch_move( self, on_touch_move: impl Into<EventHandler<Event<TouchEventData>>>, ) -> Self { ... } fn on_touch_end( self, on_touch_end: impl Into<EventHandler<Event<TouchEventData>>>, ) -> Self { ... } fn on_pointer_press( self, on_pointer_press: impl Into<EventHandler<Event<PointerEventData>>>, ) -> Self { ... } fn on_pointer_down( self, on_pointer_down: impl Into<EventHandler<Event<PointerEventData>>>, ) -> Self { ... } fn on_pointer_move( self, on_pointer_move: impl Into<EventHandler<Event<PointerEventData>>>, ) -> Self { ... } fn on_pointer_enter( self, on_pointer_enter: impl Into<EventHandler<Event<PointerEventData>>>, ) -> Self { ... } fn on_pointer_leave( self, on_pointer_leave: impl Into<EventHandler<Event<PointerEventData>>>, ) -> Self { ... } fn on_pointer_over( self, on_pointer_over: impl Into<EventHandler<Event<PointerEventData>>>, ) -> Self { ... } fn on_pointer_out( self, on_pointer_out: impl Into<EventHandler<Event<PointerEventData>>>, ) -> Self { ... } fn on_file_drop( self, on_file_drop: impl Into<EventHandler<Event<FileEventData>>>, ) -> Self { ... } fn on_global_file_hover( self, on_global_file_hover: impl Into<EventHandler<Event<FileEventData>>>, ) -> Self { ... } fn on_global_file_hover_cancelled( self, on_global_file_hover_cancelled: impl Into<EventHandler<Event<FileEventData>>>, ) -> Self { ... } fn on_ime_preedit( self, on_ime_preedit: impl Into<EventHandler<Event<ImePreeditEventData>>>, ) -> Self { ... } fn on_sized( self, on_sized: impl Into<EventHandler<Event<SizedEventData>>>, ) -> Self where Self: LayoutExt { ... } fn on_press( self, on_press: impl Into<EventHandler<Event<PressEventData>>>, ) -> Self { ... } fn on_secondary_down( self, on_secondary_down: impl Into<EventHandler<Event<PressEventData>>>, ) -> Self { ... } fn on_all_press( self, on_press: impl Into<EventHandler<Event<PressEventData>>>, ) -> Self { ... } fn on_focus_press( self, on_focus_press: impl Into<EventHandler<Event<FocusPressEventData>>>, ) -> Self { ... }
}
Expand description

Methods for attaching event handlers to an element.

Many events come in three flavors: the plain one fires only while the pointer is over the element; the global_ variants fire no matter where the event happens; and the capture_ variants fire during the top-down capture phase, before the event reaches the inner element.

For high-level press handling, prefer on_press over the raw mouse/pointer events.

Required Methods§

Source

fn get_event_handlers(&mut self) -> &mut FxHashMap<EventName, EventHandlerType>

Returns a mutable reference to the element’s event handler map.

Provided Methods§

Source

fn with_event_handlers( self, event_handlers: FxHashMap<EventName, EventHandlerType>, ) -> Self

Replace all of this element’s event handlers with the given map.

Source

fn on_mouse_down( self, on_mouse_down: impl Into<EventHandler<Event<MouseEventData>>>, ) -> Self

Fires when a mouse button is pressed down over the element.

Source

fn on_mouse_up( self, on_mouse_up: impl Into<EventHandler<Event<MouseEventData>>>, ) -> Self

Fires when a mouse button is released over the element.

Source

fn on_mouse_move( self, on_mouse_move: impl Into<EventHandler<Event<MouseEventData>>>, ) -> Self

Fires when the cursor moves over the element.

Source

fn on_global_pointer_press( self, on_global_pointer_press: impl Into<EventHandler<Event<PointerEventData>>>, ) -> Self

Fires when a pointer (mouse or touch) is pressed anywhere, even outside the element.

Source

fn on_global_pointer_down( self, on_global_pointer_down: impl Into<EventHandler<Event<PointerEventData>>>, ) -> Self

Fires when a pointer (mouse or touch) goes down anywhere, even outside the element.

Source

fn on_global_pointer_move( self, on_global_pointer_move: impl Into<EventHandler<Event<PointerEventData>>>, ) -> Self

Fires when a pointer (mouse or touch) moves anywhere, even outside the element.

Source

fn on_capture_global_pointer_move( self, on_capture_global_pointer_move: impl Into<EventHandler<Event<PointerEventData>>>, ) -> Self

Like on_global_pointer_move, but fires during the top-down capture phase.

Source

fn on_capture_global_pointer_press( self, on_capture_global_pointer_press: impl Into<EventHandler<Event<PointerEventData>>>, ) -> Self

Like on_global_pointer_press, but fires during the top-down capture phase.

Source

fn on_key_down( self, on_key_down: impl Into<EventHandler<Event<KeyboardEventData>>>, ) -> Self

Fires when a key is pressed down while the element is focused.

Source

fn on_key_up( self, on_key_up: impl Into<EventHandler<Event<KeyboardEventData>>>, ) -> Self

Fires when a key is released while the element is focused.

Source

fn on_global_key_down( self, on_global_key_down: impl Into<EventHandler<Event<KeyboardEventData>>>, ) -> Self

Fires when a key is pressed down, regardless of which element is focused.

Source

fn on_global_key_up( self, on_global_key_up: impl Into<EventHandler<Event<KeyboardEventData>>>, ) -> Self

Fires when a key is released, regardless of which element is focused.

Source

fn on_wheel( self, on_wheel: impl Into<EventHandler<Event<WheelEventData>>>, ) -> Self

Fires when the scroll wheel is used over the element.

Source

fn on_touch_cancel( self, on_touch_cancel: impl Into<EventHandler<Event<TouchEventData>>>, ) -> Self

Fires when an ongoing touch is cancelled by the system.

Source

fn on_touch_start( self, on_touch_start: impl Into<EventHandler<Event<TouchEventData>>>, ) -> Self

Fires when a touch point is placed on the element.

Source

fn on_touch_move( self, on_touch_move: impl Into<EventHandler<Event<TouchEventData>>>, ) -> Self

Fires when a touch point moves across the element.

Source

fn on_touch_end( self, on_touch_end: impl Into<EventHandler<Event<TouchEventData>>>, ) -> Self

Fires when a touch point is lifted from the element.

Source

fn on_pointer_press( self, on_pointer_press: impl Into<EventHandler<Event<PointerEventData>>>, ) -> Self

Fires when the element is pressed and released by a pointer (mouse or touch).

Source

fn on_pointer_down( self, on_pointer_down: impl Into<EventHandler<Event<PointerEventData>>>, ) -> Self

Fires when a pointer (mouse or touch) goes down over the element.

Source

fn on_pointer_move( self, on_pointer_move: impl Into<EventHandler<Event<PointerEventData>>>, ) -> Self

Fires when a pointer (mouse or touch) moves over the element.

Source

fn on_pointer_enter( self, on_pointer_enter: impl Into<EventHandler<Event<PointerEventData>>>, ) -> Self

Fires when a pointer enters the element.

Source

fn on_pointer_leave( self, on_pointer_leave: impl Into<EventHandler<Event<PointerEventData>>>, ) -> Self

Fires when a pointer leaves the element.

Source

fn on_pointer_over( self, on_pointer_over: impl Into<EventHandler<Event<PointerEventData>>>, ) -> Self

Fires when a pointer is over the element, including over its children.

Source

fn on_pointer_out( self, on_pointer_out: impl Into<EventHandler<Event<PointerEventData>>>, ) -> Self

Fires when a pointer leaves the element or one of its children.

Source

fn on_file_drop( self, on_file_drop: impl Into<EventHandler<Event<FileEventData>>>, ) -> Self

Fires when a file is dropped onto the element.

Source

fn on_global_file_hover( self, on_global_file_hover: impl Into<EventHandler<Event<FileEventData>>>, ) -> Self

Fires when a dragged file hovers anywhere over the window.

Source

fn on_global_file_hover_cancelled( self, on_global_file_hover_cancelled: impl Into<EventHandler<Event<FileEventData>>>, ) -> Self

Fires when a dragged file stops hovering over the window.

Source

fn on_ime_preedit( self, on_ime_preedit: impl Into<EventHandler<Event<ImePreeditEventData>>>, ) -> Self

Fires while text is being composed through an input method editor (IME).

Source

fn on_sized( self, on_sized: impl Into<EventHandler<Event<SizedEventData>>>, ) -> Self
where Self: LayoutExt,

Fires when the element’s measured size or position changes.

Source

fn on_press( self, on_press: impl Into<EventHandler<Event<PressEventData>>>, ) -> Self

This is generally the best event in which to run “press” logic, this might be called onClick, onActivate, or onConnect in other platforms.

Gets triggered when:

  • Click: There is a MouseUp event (Left button) with the in the same element that there had been a MouseDown just before
  • Touched: There is a TouchEnd event in the same element that there had been a TouchStart just before
  • Activated: The element is focused and there is a keydown event pressing the OS activation key (e.g Space, Enter)
Source

fn on_secondary_down( self, on_secondary_down: impl Into<EventHandler<Event<PressEventData>>>, ) -> Self

Also called the context menu click in other platforms. Gets triggered when:

  • Click: There is a MouseDown (Right button) event
Source

fn on_all_press( self, on_press: impl Into<EventHandler<Event<PressEventData>>>, ) -> Self

Gets triggered when:

  • Click: There is a MouseUp event (Any button) with the in the same element that there had been a MouseDown just before
  • Touched: There is a TouchEnd event in the same element that there had been a TouchStart just before
  • Activated: The element is focused and there is a keydown event pressing the OS activation key (e.g Space, Enter)
Source

fn on_focus_press( self, on_focus_press: impl Into<EventHandler<Event<FocusPressEventData>>>, ) -> Self

Gets triggered when:

  • Started clicking: There is a MouseDown event (Left button)
  • Touched: There is a TouchEnd event in the same element that there had been a TouchStart just before

This event is intended to focus elements such as text inputs following each platform style.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§