Trait vizia_core::modifiers::ActionModifiers

source ·
pub trait ActionModifiers<V> {
Show 17 methods // Required methods fn on_press<F>(self, action: F) -> Self where F: 'static + Fn(&mut EventContext<'_>) + Send + Sync; fn on_press_down<F>(self, action: F) -> Self where F: 'static + Fn(&mut EventContext<'_>) + Send + Sync; fn on_double_click<F>(self, action: F) -> Self where F: 'static + Fn(&mut EventContext<'_>, MouseButton) + Send + Sync; fn on_hover<F>(self, action: F) -> Self where F: 'static + Fn(&mut EventContext<'_>) + Send + Sync; fn on_hover_out<F>(self, action: F) -> Self where F: 'static + Fn(&mut EventContext<'_>) + Send + Sync; fn on_over<F>(self, action: F) -> Self where F: 'static + Fn(&mut EventContext<'_>) + Send + Sync; fn on_over_out<F>(self, action: F) -> Self where F: 'static + Fn(&mut EventContext<'_>) + Send + Sync; fn on_mouse_move<F>(self, action: F) -> Self where F: 'static + Fn(&mut EventContext<'_>, f32, f32) + Send + Sync; fn on_mouse_down<F>(self, action: F) -> Self where F: 'static + Fn(&mut EventContext<'_>, MouseButton) + Send + Sync; fn on_mouse_up<F>(self, action: F) -> Self where F: 'static + Fn(&mut EventContext<'_>, MouseButton) + Send + Sync; fn on_focus_in<F>(self, action: F) -> Self where F: 'static + Fn(&mut EventContext<'_>) + Send + Sync; fn on_focus_out<F>(self, action: F) -> Self where F: 'static + Fn(&mut EventContext<'_>) + Send + Sync; fn on_geo_changed<F>(self, action: F) -> Self where F: 'static + Fn(&mut EventContext<'_>, GeoChanged) + Send + Sync; fn tooltip<C: Fn(&mut Context) -> Handle<'_, Tooltip> + 'static>( self, content: C, ) -> Self; fn menu<C: FnOnce(&mut Context) -> Handle<'_, T>, T: View>( self, content: C, ) -> Self; fn on_drag<F>(self, action: F) -> Self where F: 'static + Fn(&mut EventContext<'_>) + Send + Sync; fn on_drop<F>(self, action: F) -> Self where F: 'static + Fn(&mut EventContext<'_>, DropData) + Send + Sync;
}
Expand description

Modifiers which add an action callback to a view.

Required Methods§

source

fn on_press<F>(self, action: F) -> Self
where F: 'static + Fn(&mut EventContext<'_>) + Send + Sync,

Adds a callback which is performed when the the view receives the Press event. By default a view receives the Press event when the left mouse button is pressed and then released on the view, or when the space or enter keys are pressed and then released while the view is focused.

§Example
Element::new(cx).on_press(|_| debug!("View was pressed!"));
source

fn on_press_down<F>(self, action: F) -> Self
where F: 'static + Fn(&mut EventContext<'_>) + Send + Sync,

Adds a callback which is performed when the the view receives the PressDown event. or when the space or enter keys are pressed while the view is focused.

§Example
Element::new(cx).on_press_down(|_| debug!("View was pressed down!"));
source

fn on_double_click<F>(self, action: F) -> Self
where F: 'static + Fn(&mut EventContext<'_>, MouseButton) + Send + Sync,

Adds a callback which is performed when the the view receives the MouseDoubleClick event.

§Example
Element::new(cx).on_double_click(|_, _button| debug!("View was double clicked on!"));
source

fn on_hover<F>(self, action: F) -> Self
where F: 'static + Fn(&mut EventContext<'_>) + Send + Sync,

Adds a callback which is performed when the mouse pointer moves over a view. This callback is not triggered when the mouse pointer moves over an overlapping child of the view.

§Example
Element::new(cx).on_hover(|_| debug!("Mouse cursor entered the view!"));
source

fn on_hover_out<F>(self, action: F) -> Self
where F: 'static + Fn(&mut EventContext<'_>) + Send + Sync,

Adds a callback which is performed when the mouse pointer moves away from a view. This callback is not triggered when the mouse pointer moves away from an overlapping child of the view.

§Example
Element::new(cx).on_hover_out(|_| debug!("Mouse cursor left the view!"));
source

fn on_over<F>(self, action: F) -> Self
where F: 'static + Fn(&mut EventContext<'_>) + Send + Sync,

Adds a callback which is performed when the mouse pointer moves over the bounds of a view, including any overlapping children.

§Example
Element::new(cx).on_over(|_| debug!("Mouse cursor entered the view bounds!"));
source

fn on_over_out<F>(self, action: F) -> Self
where F: 'static + Fn(&mut EventContext<'_>) + Send + Sync,

Adds a callback which is performed when the mouse pointer moves away from the bounds of a view, including any overlapping children.

§Example
Element::new(cx).on_over_out(|_| debug!("Mouse cursor left the view bounds!"));
source

fn on_mouse_move<F>(self, action: F) -> Self
where F: 'static + Fn(&mut EventContext<'_>, f32, f32) + Send + Sync,

Adds a callback which is performed when the mouse pointer moves within the bounds of a view.

§Example
Element::new(cx).on_mouse_move(|_, x, y| debug!("Cursor moving: {} {}", x, y));
source

fn on_mouse_down<F>(self, action: F) -> Self
where F: 'static + Fn(&mut EventContext<'_>, MouseButton) + Send + Sync,

Adds a callback which is performed when a mouse button is pressed on the view. Unlike the on_press callback, this callback is triggered for all mouse buttons and not for any keyboard keys.

§Example
Element::new(cx).on_mouse_down(|_, button| debug!("Mouse button, {:?}, was pressed!", button));
source

fn on_mouse_up<F>(self, action: F) -> Self
where F: 'static + Fn(&mut EventContext<'_>, MouseButton) + Send + Sync,

Adds a callback which is performed when a mouse button is released on the view. Unlike the on_release callback, this callback is triggered for all mouse buttons and not for any keyboard keys.

§Example
Element::new(cx).on_mouse_up(|_, button| debug!("Mouse button, {:?}, was released!", button));
source

fn on_focus_in<F>(self, action: F) -> Self
where F: 'static + Fn(&mut EventContext<'_>) + Send + Sync,

Adds a callback which is performed when the view gains keyboard focus.

§Example
Element::new(cx).on_focus_in(|_| debug!("View gained keyboard focus!"));
source

fn on_focus_out<F>(self, action: F) -> Self
where F: 'static + Fn(&mut EventContext<'_>) + Send + Sync,

Adds a callback which is performed when the view loses keyboard focus.

§Example
Element::new(cx).on_focus_out(|_| debug!("View lost keyboard focus!"));
source

fn on_geo_changed<F>(self, action: F) -> Self
where F: 'static + Fn(&mut EventContext<'_>, GeoChanged) + Send + Sync,

Adds a callback which is performed when the the view changes size or position after layout.

§Example
Element::new(cx).on_geo_changed(|_, _| debug!("View geometry changed!"));
source

fn tooltip<C: Fn(&mut Context) -> Handle<'_, Tooltip> + 'static>( self, content: C, ) -> Self

source

fn menu<C: FnOnce(&mut Context) -> Handle<'_, T>, T: View>( self, content: C, ) -> Self

source

fn on_drag<F>(self, action: F) -> Self
where F: 'static + Fn(&mut EventContext<'_>) + Send + Sync,

source

fn on_drop<F>(self, action: F) -> Self
where F: 'static + Fn(&mut EventContext<'_>, DropData) + Send + Sync,

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<'a, V: View> ActionModifiers<V> for Handle<'a, V>