Expand description
Mouse service, properties, events and other types.
The example below defines a window that shows the pressed mouse buttons and prints the button state changes. The pressed buttons text follows the cursor position.
use zng::prelude::*;
Window! {
child_align = layout::Align::TOP_LEFT;
child = Text! {
txt = mouse::MOUSE.buttons().map_debug();
layout::offset = mouse::MOUSE.position().map(|p| match p {
Some(p) => layout::Vector::from(p.position.to_vector()) - layout::Vector::new(0, 100.pct()),
None => layout::Vector::zero(),
});
};
mouse::on_mouse_input = hn!(|args: &mouse::MouseInputArgs| {
println!("button {:?} {:?}", args.button, args.state);
});
}
Mouse events are send to the top widget under the cursor. This module also provides mouse exclusive gestures like mouse clicks
and mouse hovered, these gestures are composed with others in gesture
to provide the final pointer gestures. You should
prefer using gesture::on_click
over on_mouse_click
, unless you really want to exclusively handle mouse clicks.
§Full API
See zng_ext_input::mouse
and zng_wgt_input::mouse
for the full mouse API.
Modules§
- Raw mouse hardware events, received independent of what window is under the pointer.
Structs§
- Settings that define the mouse button pressed repeat.
- Defines how click events are generated for a widget.
- Window custom cursor.
- Mouse service.
MOUSE_CLICK_EVENT
arguments.MOUSE_HOVERED_EVENT
arguments.MOUSE_INPUT_EVENT
arguments.MOUSE_MOVE_EVENT
arguments.- Mouse cursor position.
MOUSE_WHEEL_EVENT
arguments.- System settings needed for implementing double/triple clicks.
Enums§
- State a
MouseButton
has entered. - Represents mouse gestures that can initiate a click.
- Named system dependent cursor icon.
- Window cursor source.
- Describes a button of a mouse controller.
- Describes a difference in the mouse scroll wheel state.
Statics§
- Mouse click event, any
click_count
. - The top-most hovered widget changed or pointer capture changed.
- Mouse down or up event.
- Mouse move event.
- Mouse wheel scroll event.
Traits§
- Mouse config builder methods.
- Mouse config methods.
Functions§
P
Defines how click events are generated for the widget.P
Sets the mouse pointer cursor displayed when hovering the widget.P
If the mouse pointer is pressed or captured by the widget and it is enabled.P
If the mouse pointer is pressed in the widget and it is enabled.P
Mouse clicked on the disabled widget with any button, including repeat clicks.P
Mouse clicked on the disabled widget with the primary button, including repeat clicks.P
Mouse entered or left the widget and descendant widgets area, the widget is disabled and cursor capture allows it.P
Mouse button pressed or release while the cursor is over the widget, the widget is disabled and no cursor capture blocks it.P
Mouse wheel scrolled while pointer is hovering widget and it is disabled.P
Mouse clicked on the widget with any button and including repeat clicks and it is enabled.P
Mouse double clicked on the widget with any button and it is enabled.P
Mouse clicked on the widget with any button but excluding repeat clicks and it is enabled.P
Mouse triple clicked on the widget with any button and it is enabled.P
Mouse clicked on the widget with the primary button including repeat clicks and it is enabled.P
Mouse double clicked on the widget with the primary button and it is enabled.P
Mouse button pressed while the cursor is over the widget, the widget is enabled and cursor capture allows it.P
Mouse is now over the widget or a descendant widget, the widget is enabled and cursor capture allows it.P
Mouse entered or left the widget and descendant widgets area, the widget is enabled and cursor capture allows it.P
Mouse button pressed or released while the cursor is over the widget, the widget is enabled and no cursor capture blocks it.P
Mouse is no longer over the widget or any descendant widget, the widget is enabled and cursor capture allows it.P
Mouse cursor moved over the widget and cursor capture allows it.P
Mouse wheel scrolled while pointer is hovering the widget and the pressed keyboard modifiers allow a scroll operation and the widget is enabled.P
Mouse clicked on the widget with the primary button excluding repeat clicks and it is enabled.P
Mouse triple clicked on the widget with the primary button and it is enabled.P
Mouse button released while the cursor if over the widget, the widget is enabled and cursor capture allows it.P
Mouse wheel scrolled while pointer is hovering widget and it is enabled.P
Mouse wheel scrolled while pointer is hovering the widget and the pressed keyboard modifiers allow a zoom operation and the widget is enabled.P
Previewon_disabled_mouse_any_click
event.P
Previewon_disabled_mouse_click
event.P
Previewon_disabled_mouse_hovered
event.P
Previewon_disabled_mouse_input
event.P
Previewon_disabled_mouse_wheel
event.P
Previewon_mouse_any_click
event.P
Previewon_mouse_any_double_click
event.P
Previewon_mouse_any_single_click
event.P
Previewon_mouse_any_triple_click
event.P
Previewon_mouse_click
event.P
Previewon_mouse_double_click
event.P
Previewon_mouse_down
event.P
Previewon_mouse_enter
event.P
Previewon_mouse_hovered
event.P
Previewon_mouse_input
event.P
Previewon_mouse_leave
event.P
Previewon_mouse_move
event.P
Previewon_mouse_scroll
event.P
Previewon_mouse_single_click
event.P
Previewon_mouse_triple_click
event.P
Previewon_mouse_up
event.P
Previewon_mouse_wheel
event.P
Previewon_mouse_zoom
event.