Module mouse

Module mouse 

Source
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§

ButtonRepeatConfig
Settings that define the mouse button pressed repeat.
ClickMode
Defines how click events are generated for a widget.
CursorImg
Window custom cursor.
MOUSE
Mouse service.
MouseClickArgs
MOUSE_CLICK_EVENT arguments.
MouseHoverArgs
MOUSE_HOVERED_EVENT arguments.
MouseInputArgs
MOUSE_INPUT_EVENT arguments.
MouseMoveArgs
MOUSE_MOVE_EVENT arguments.
MousePosition
Mouse cursor position.
MouseWheelArgs
MOUSE_WHEEL_EVENT arguments.
MultiClickConfig
System settings needed for implementing double/triple clicks.

Enums§

ButtonState
State a MouseButton has entered.
ClickTrigger
Represents mouse gestures that can initiate a click.
CursorIcon
Named system dependent cursor icon.
CursorSource
Window cursor source.
MouseButton
Describes a button of a mouse controller.
MouseScrollDelta
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§

WidgetInfoBuilderMouseExt
Mouse config builder methods.
WidgetInfoMouseExt
Mouse config methods.

Functions§

click_mode
P Defines how click events are generated for the widget.
ctrl_scroll
P Defines if MouseWheelArgs gesture is_scroll when CTRL is pressed and is_zoom when no modifier is pressed.
cursor
P Sets the mouse pointer cursor displayed when hovering the widget.
is_cap_mouse_pressed
P If the mouse pointer is pressed or captured by the widget and it is enabled.
is_mouse_active
P If the mouse pointer moved over or interacted with the widget within a time duration defined by contextual mouse_active_config.
is_mouse_pressed
P If the mouse pointer is pressed in the widget and it is enabled.
mouse_active_config
P Contextual configuration for is_mouse_active.
on_disabled_mouse_any_click
P Mouse clicked on the disabled widget with any button, including repeat clicks.
on_disabled_mouse_click
P Mouse clicked on the disabled widget with the primary button, including repeat clicks.
on_disabled_mouse_hovered
P Mouse entered or left the widget and descendant widgets area, the widget is disabled and cursor capture allows it.
on_disabled_mouse_input
P Mouse 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
P Mouse wheel scrolled while pointer is hovering widget and it is disabled.
on_mouse_any_click
P Mouse clicked on the widget with any button and including repeat clicks and it is enabled.
on_mouse_any_double_click
P Mouse double clicked on the widget with any button and it is enabled.
on_mouse_any_single_click
P Mouse clicked on the widget with any button but excluding repeat clicks and it is enabled.
on_mouse_any_triple_click
P Mouse triple clicked on the widget with any button and it is enabled.
on_mouse_click
P Mouse clicked on the widget with the primary button including repeat clicks and it is enabled.
on_mouse_double_click
P Mouse double clicked on the widget with the primary button and it is enabled.
on_mouse_down
P Mouse button pressed while the cursor is over the widget, the widget is enabled and cursor capture allows it.
on_mouse_enter
P Mouse is now over the widget or a descendant widget, the widget is enabled and cursor capture allows it.
on_mouse_hovered
P Mouse entered or left the widget and descendant widgets area, the widget is enabled and cursor capture allows it.
on_mouse_input
P Mouse button pressed or released while the cursor is over the widget, the widget is enabled and no cursor capture blocks it.
on_mouse_leave
P Mouse is no longer over the widget or any descendant widget, the widget is enabled and cursor capture allows it.
on_mouse_move
P Mouse cursor moved over the widget and cursor capture allows it.
on_mouse_scroll
P Mouse 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
P Mouse clicked on the widget with the primary button excluding repeat clicks and it is enabled.
on_mouse_triple_click
P Mouse triple clicked on the widget with the primary button and it is enabled.
on_mouse_up
P Mouse button released while the cursor if over the widget, the widget is enabled and cursor capture allows it.
on_mouse_wheel
P Mouse wheel scrolled while pointer is hovering widget and it is enabled.
on_mouse_zoom
P Mouse 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
P Preview on_disabled_mouse_any_click event.
on_pre_disabled_mouse_click
P Preview on_disabled_mouse_click event.
on_pre_disabled_mouse_hovered
P Preview on_disabled_mouse_hovered event.
on_pre_disabled_mouse_input
P Preview on_disabled_mouse_input event.
on_pre_disabled_mouse_wheel
P Preview on_disabled_mouse_wheel event.
on_pre_mouse_any_click
P Preview on_mouse_any_click event.
on_pre_mouse_any_double_click
P Preview on_mouse_any_double_click event.
on_pre_mouse_any_single_click
P Preview on_mouse_any_single_click event.
on_pre_mouse_any_triple_click
P Preview on_mouse_any_triple_click event.
on_pre_mouse_click
P Preview on_mouse_click event.
on_pre_mouse_double_click
P Preview on_mouse_double_click event.
on_pre_mouse_down
P Preview on_mouse_down event.
on_pre_mouse_enter
P Preview on_mouse_enter event.
on_pre_mouse_hovered
P Preview on_mouse_hovered event.
on_pre_mouse_input
P Preview on_mouse_input event.
on_pre_mouse_leave
P Preview on_mouse_leave event.
on_pre_mouse_move
P Preview on_mouse_move event.
on_pre_mouse_scroll
P Preview on_mouse_scroll event.
on_pre_mouse_single_click
P Preview on_mouse_single_click event.
on_pre_mouse_triple_click
P Preview on_mouse_triple_click event.
on_pre_mouse_up
P Preview on_mouse_up event.
on_pre_mouse_wheel
P Preview on_mouse_wheel event.
on_pre_mouse_zoom
P Preview on_mouse_zoom event.