zng/
gesture.rs

1//! Gesture service, properties, events, shortcuts and other types.
2//!
3//! A gesture is an event that is generated from multiple lower-level events. A shortcut is a gesture generated
4//! from one or more keyboard inputs, a click is also a gesture generated from mouse clicks, accessibility clicks,
5//! touch taps and some shortcuts. In essence, events, types and states that aggregate multiple difference sources
6//! are found here, gestures generated from a single event source are defined in other modules, for example touch gestures
7//! are defined in [`touch`](crate::touch).
8//!
9//! ```
10//! use zng::prelude::*;
11//!
12//! # let _scope = APP.defaults();
13//! # let _ =
14//! Window! {
15//!     gesture::on_click = hn!(|args: &gesture::ClickArgs| {
16//!         use gesture::ClickArgsSource::*;
17//!         match args.source {
18//!             Mouse { .. } => println!("mouse click"),
19//!             Touch { .. } => println!("touch tap"),
20//!             Shortcut { .. } => println!("shortcut press"),
21//!             Access { .. } => println!("access click"),
22//!         }
23//!     });
24//! }
25//! # ;
26//! ```
27//!
28//! The example above handles the click gesture on a window and prints what underlying event was interpreted as a click.
29//!
30//! # Full API
31//!
32//! See [`zng_ext_input::gesture`] and [`zng_wgt_input::gesture`] for the full gesture API
33//! and [`zng_app::shortcut`] for the shortcut API.
34//!
35//! [`zng_app::shortcut`]: mod@zng_app::shortcut
36
37pub use zng_ext_input::gesture::{
38    CLICK_EVENT, ClickArgs, ClickArgsSource, CommandShortcutMatchesExt, GESTURES, HeadlessAppGestureExt, SHORTCUT_EVENT, ShortcutActions,
39    ShortcutArgs, ShortcutClick, ShortcutsHandle, WeakShortcutsHandle,
40};
41
42pub use zng_app::shortcut::{
43    CommandShortcutExt, GestureKey, KeyChord, KeyGesture, ModifierGesture, Shortcut, ShortcutFilter, Shortcuts, shortcut,
44};
45
46pub use zng_wgt_input::gesture::{
47    click_shortcut, context_click_shortcut, on_any_click, on_any_double_click, on_any_single_click, on_any_triple_click, on_click,
48    on_context_click, on_disabled_click, on_double_click, on_pre_any_click, on_pre_any_double_click, on_pre_any_single_click,
49    on_pre_any_triple_click, on_pre_click, on_pre_context_click, on_pre_disabled_click, on_pre_double_click, on_pre_single_click,
50    on_pre_triple_click, on_single_click, on_triple_click,
51};
52
53pub use zng_wgt_input::{is_cap_hovered, is_cap_pointer_pressed, is_cap_pressed, is_hovered, is_hovered_disabled, is_pressed};