Expand description
Touch service, properties, events and other types.
The example below defines a window that shows the active touches and prints the touch state changes. The touch’s text follows the first touch position.
use zng::prelude::*;
Window! {
child_align = layout::Align::TOP_LEFT;
child = Text! {
txt = touch::TOUCH.positions().map(|p| {
let mut t = Txt::from("[\n");
for p in p {
use std::fmt::Write as _;
writeln!(&mut t, " ({:?}, {:?})", p.touch, p.position).unwrap();
}
t.push(']');
t.end_mut();
t
});
font_size = 1.4.em();
layout::offset = touch::TOUCH.positions().map(|p| match p.first() {
Some(p) => layout::Vector::from(p.position.to_vector()) - layout::Vector::new(0, 100.pct()),
None => layout::Vector::zero(),
});
};
touch::on_touch_input = hn!(|args: &touch::TouchInputArgs| {
println!("touch {:?} {:?}", args.touch, args.phase);
});
}
Touch events are send to the top widget under the touch point. This module also provides touch exclusive gestures like
tap, touch enter/leave and on_touch_transform
. Note some touch gestures are composed with others in gesture
to provide the
final pointer gestures. You should prefer using gesture::on_click
over on_touch_tap
, unless you really want to exclusively
touch clicks.
§Full API
See zng_ext_input::touch
and zng_wgt_input::touch
for the full touch API.
Structs§
- Touch service.
- System settings needed to implementing touch gestures.
- Identifier for a continuous touch contact.
- Arguments for
TOUCH_INPUT_EVENT
. - Arguments for
TOUCH_LONG_PRESS_EVENT
. - Identify the moves of one touch contact in
TouchMoveArgs
. - Arguments for
TOUCH_MOVE_EVENT
. - Active touch positions.
- Arguments for
TOUCH_TAP_EVENT
. - Arguments for
TOUCH_TRANSFORM_EVENT
. - Info useful for touch gestures computed from two touch points.
- Defines the different transforms that a touch transform can do to keep two touch points in a widget aligned with the touch contacts.
- Identify a new touch contact or a contact update.
- Arguments for
TOUCHED_EVENT
.
Enums§
- Describes the force of a touch event.
- Describes touch-screen input state.
Statics§
- Touch made first contact or lost contact with a widget.
- Touch contact started or ended.
- Touch contact pressed without moving for more then the
tap_max_time
. - Touch contact moved.
- Touch tap.
- Two point touch transform.
Functions§
P
If a touch contact point is over the widget, or is over a descendant, or is captured by it.P
If a touch contact point is over the widget or a descendant and the it is enabled.P
If a touch contact that started over the widget is over it and it is enabled.P
Touch contact started or ended over the widget, it is disabled and cursor capture allows it.P
Single touch contact was made and held in place for a duration of time (default 500ms) on the widget and the widget is disabled.P
Touch tap on the widget and it is disabled.P
Previewon_disabled_touch_input
event.P
Previewon_disabled_touch_long_press
event.P
Previewon_disabled_touch_tap
event.P
Previewon_touch_cancel
event.P
Previewon_touch_end
event.P
Previewon_touch_enter
event.P
Previewon_touch_input
event.P
Previewon_touch_leave
event.P
Previewon_touch_long_press
event.P
Previewon_touch_move
event.P
Previewon_touch_start
event.P
Previewon_touch_tap
event.P
Previewon_touch_transform
event.P
Previewon_touched
event.P
Touch contact canceled over the widget, it is enabled and cursor capture allows it.P
Touch contact ended over the widget, it is enabled and cursor capture allows it.P
Touch contact is now over the widget or a descendant and it is enabled.P
Touch contact started or ended over the widget, it is enabled and cursor capture allows it.P
Touch contact is no longer over the widget or any descendant and it is enabled.P
Single touch contact was made and held in place for a duration of time (default 500ms) on the widget and the widget is enabled.P
Touch contact moved over the widget and cursor capture allows it.P
Touch contact started over the widget, it is enabled and cursor capture allows it.P
Touch tap on the widget and it is enabled.P
Touch gesture to translate, scale or rotate happened over this widget.P
Touch contact entered or left the widget and descendants area and it is enabled.P
Applies transforms from touch gestures on the widget.