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(false);
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| {
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_
device_ events - Raw mouse hardware events, received independent of what window is under the pointer.
Structs§
- Button
Repeat Config - Settings that define the mouse button pressed repeat.
- Click
Mode - Defines how click events are generated for a widget.
- Cursor
Img - Window custom cursor.
- MOUSE
- Mouse service.
- Mouse
Click Args MOUSE_CLICK_EVENTarguments.- Mouse
Hover Args MOUSE_HOVERED_EVENTarguments.- Mouse
Input Args MOUSE_INPUT_EVENTarguments.- Mouse
Move Args MOUSE_MOVE_EVENTarguments.- Mouse
Position - Mouse cursor position.
- Mouse
Wheel Args MOUSE_WHEEL_EVENTarguments.- Multi
Click Config - System settings needed for implementing double/triple clicks.
Enums§
- Button
State - State a
MouseButtonhas entered. - Click
Trigger - Represents mouse gestures that can initiate a click.
- Cursor
Icon - Named system dependent cursor icon.
- Cursor
Source - Window cursor source.
- Mouse
Button - Describes a button of a mouse controller.
- Mouse
Scroll Delta - Describes a difference in the mouse scroll wheel state.
Statics§
- MOUSE_
CLICK_ EVENT - Mouse click event, any
click_count. - MOUSE_
HOVERED_ EVENT - The top-most hovered widget changed or pointer capture changed.
- MOUSE_
INPUT_ EVENT - Mouse down or up event.
- MOUSE_
MOVE_ EVENT - Mouse move event.
- MOUSE_
WHEEL_ EVENT - Mouse wheel scroll event.
Traits§
- Widget
Info Builder Mouse Ext - Mouse config builder methods.
- Widget
Info Mouse Ext - Mouse config methods.
Functions§
- click_
mode PDefines how click events are generated for the widget.- ctrl_
scroll PDefines ifMouseWheelArgsgestureis_scrollwhenCTRLis pressed andis_zoomwhen no modifier is pressed.- cursor
PSets the mouse pointer cursor displayed when hovering the widget.- is_
cap_ mouse_ pressed PIf the mouse pointer is pressed or captured by the widget and it is enabled.- is_
mouse_ active PIf the mouse pointer moved over or interacted with the widget within a time duration defined by contextualmouse_active_config.- is_
mouse_ pressed PIf the mouse pointer is pressed in the widget and it is enabled.- mouse_
active_ config PContextual configuration foris_mouse_active.- on_
disabled_ mouse_ any_ click PMouse clicked on the disabled widget with any button, including repeat clicks.- on_
disabled_ mouse_ click PMouse clicked on the disabled widget with the primary button, including repeat clicks.- on_
disabled_ mouse_ hovered PMouse entered or left the widget and descendant widgets area, the widget is disabled and cursor capture allows it.- on_
disabled_ mouse_ input PMouse button pressed or release while the cursor is over the widget, the widget is disabled and no cursor capture blocks it.- on_
disabled_ mouse_ wheel PMouse wheel scrolled while pointer is hovering widget and it is disabled.- on_
mouse_ any_ click PMouse clicked on the widget with any button and including repeat clicks and it is enabled.- on_
mouse_ any_ double_ click PMouse double clicked on the widget with any button and it is enabled.- on_
mouse_ any_ single_ click PMouse clicked on the widget with any button but excluding repeat clicks and it is enabled.- on_
mouse_ any_ triple_ click PMouse triple clicked on the widget with any button and it is enabled.- on_
mouse_ click PMouse clicked on the widget with the primary button including repeat clicks and it is enabled.- on_
mouse_ double_ click PMouse double clicked on the widget with the primary button and it is enabled.- on_
mouse_ down PMouse button pressed while the cursor is over the widget, the widget is enabled and cursor capture allows it.- on_
mouse_ enter PMouse is now over the widget or a descendant widget, the widget is enabled and cursor capture allows it.- on_
mouse_ hovered PMouse entered or left the widget and descendant widgets area, the widget is enabled and cursor capture allows it.- on_
mouse_ input PMouse button pressed or released while the cursor is over the widget, the widget is enabled and no cursor capture blocks it.- on_
mouse_ leave PMouse is no longer over the widget or any descendant widget, the widget is enabled and cursor capture allows it.- on_
mouse_ move PMouse cursor moved over the widget and cursor capture allows it.- on_
mouse_ scroll PMouse wheel scrolled while pointer is hovering the widget and the pressed keyboard modifiers allow a scroll operation and the widget is enabled.- on_
mouse_ single_ click PMouse clicked on the widget with the primary button excluding repeat clicks and it is enabled.- on_
mouse_ triple_ click PMouse triple clicked on the widget with the primary button and it is enabled.- on_
mouse_ up PMouse button released while the cursor if over the widget, the widget is enabled and cursor capture allows it.- on_
mouse_ wheel PMouse wheel scrolled while pointer is hovering widget and it is enabled.- on_
mouse_ zoom PMouse wheel scrolled while pointer is hovering the widget and the pressed keyboard modifiers allow a zoom operation and the widget is enabled.- on_
pre_ disabled_ mouse_ any_ click PPreviewon_disabled_mouse_any_clickevent.- on_
pre_ disabled_ mouse_ click PPreviewon_disabled_mouse_clickevent.- on_
pre_ disabled_ mouse_ hovered PPreviewon_disabled_mouse_hoveredevent.- on_
pre_ disabled_ mouse_ input PPreviewon_disabled_mouse_inputevent.- on_
pre_ disabled_ mouse_ wheel PPreviewon_disabled_mouse_wheelevent.- on_
pre_ mouse_ any_ click PPreviewon_mouse_any_clickevent.- on_
pre_ mouse_ any_ double_ click PPreviewon_mouse_any_double_clickevent.- on_
pre_ mouse_ any_ single_ click PPreviewon_mouse_any_single_clickevent.- on_
pre_ mouse_ any_ triple_ click PPreviewon_mouse_any_triple_clickevent.- on_
pre_ mouse_ click PPreviewon_mouse_clickevent.- on_
pre_ mouse_ double_ click PPreviewon_mouse_double_clickevent.- on_
pre_ mouse_ down PPreviewon_mouse_downevent.- on_
pre_ mouse_ enter PPreviewon_mouse_enterevent.- on_
pre_ mouse_ hovered PPreviewon_mouse_hoveredevent.- on_
pre_ mouse_ input PPreviewon_mouse_inputevent.- on_
pre_ mouse_ leave PPreviewon_mouse_leaveevent.- on_
pre_ mouse_ move PPreviewon_mouse_moveevent.- on_
pre_ mouse_ scroll PPreviewon_mouse_scrollevent.- on_
pre_ mouse_ single_ click PPreviewon_mouse_single_clickevent.- on_
pre_ mouse_ triple_ click PPreviewon_mouse_triple_clickevent.- on_
pre_ mouse_ up PPreviewon_mouse_upevent.- on_
pre_ mouse_ wheel PPreviewon_mouse_wheelevent.- on_
pre_ mouse_ zoom PPreviewon_mouse_zoomevent.