Trait vizia::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>(self, content: C) -> Self
where C: Fn(&mut Context) -> Handle<'_, Tooltip> + 'static;
fn menu<C, T>(self, content: C) -> Self
where C: FnOnce(&mut Context) -> Handle<'_, T>,
T: View;
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§
sourcefn on_press<F>(self, action: F) -> Self
fn on_press<F>(self, action: F) -> Self
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!"));
sourcefn on_press_down<F>(self, action: F) -> Self
fn on_press_down<F>(self, action: F) -> Self
sourcefn on_double_click<F>(self, action: F) -> Self
fn on_double_click<F>(self, action: F) -> Self
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!"));
sourcefn on_hover<F>(self, action: F) -> Self
fn on_hover<F>(self, action: F) -> Self
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!"));
sourcefn on_hover_out<F>(self, action: F) -> Self
fn on_hover_out<F>(self, action: F) -> Self
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!"));
sourcefn on_over<F>(self, action: F) -> Self
fn on_over<F>(self, action: F) -> Self
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!"));
sourcefn on_over_out<F>(self, action: F) -> Self
fn on_over_out<F>(self, action: F) -> Self
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!"));
sourcefn on_mouse_move<F>(self, action: F) -> Self
fn on_mouse_move<F>(self, action: F) -> Self
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));
sourcefn on_mouse_down<F>(self, action: F) -> Self
fn on_mouse_down<F>(self, action: F) -> Self
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));
sourcefn on_mouse_up<F>(self, action: F) -> Self
fn on_mouse_up<F>(self, action: F) -> Self
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));
sourcefn on_focus_in<F>(self, action: F) -> Self
fn on_focus_in<F>(self, action: F) -> Self
Adds a callback which is performed when the view gains keyboard focus.
§Example
Element::new(cx).on_focus_in(|_| debug!("View gained keyboard focus!"));
sourcefn on_focus_out<F>(self, action: F) -> Self
fn on_focus_out<F>(self, action: F) -> Self
Adds a callback which is performed when the view loses keyboard focus.
§Example
Element::new(cx).on_focus_out(|_| debug!("View lost keyboard focus!"));
sourcefn on_geo_changed<F>(self, action: F) -> Self
fn on_geo_changed<F>(self, action: F) -> Self
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!"));