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| {
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
- Touch service.
- Touch
Config - System settings needed to implementing touch gestures.
- TouchId
- Identifier for a continuous touch contact.
- Touch
Input Args - Arguments for
TOUCH_INPUT_EVENT. - Touch
Long Press Args - Arguments for
TOUCH_LONG_PRESS_EVENT. - Touch
Move - Identify the moves of one touch contact in
TouchMoveArgs. - Touch
Move Args - Arguments for
TOUCH_MOVE_EVENT. - Touch
Position - Active touch positions.
- Touch
TapArgs - Arguments for
TOUCH_TAP_EVENT. - Touch
Transform Args - Arguments for
TOUCH_TRANSFORM_EVENT. - Touch
Transform Info - Info useful for touch gestures computed from two touch points.
- Touch
Transform Mode - Defines the different transforms that a touch transform can do to keep two touch points in a widget aligned with the touch contacts.
- Touch
Update - Identify a new touch contact or a contact update.
- Touched
Args - Arguments for
TOUCHED_EVENT.
Enums§
- Touch
Force - Describes the force of a touch event.
- Touch
Phase - Describes touch-screen input state.
Statics§
- TOUCHED_
EVENT - Touch made first contact or lost contact with a widget.
- TOUCH_
INPUT_ EVENT - Touch contact started or ended.
- TOUCH_
LONG_ PRESS_ EVENT - Touch contact pressed without moving for more then the
tap_max_time. - TOUCH_
MOVE_ EVENT - Touch contact moved.
- TOUCH_
TAP_ EVENT - Touch tap.
- TOUCH_
TRANSFORM_ EVENT - Two point touch transform.
Functions§
- is_
cap_ touched PIf a touch contact point is over the widget, or is over a descendant, or is captured by it.- is_
touch_ active PIf an unhandled touch tap has happened on the widget within a time duration defined by contextualtouch_active_config.- is_
touched PIf a touch contact point is over the widget or a descendant and the it is enabled.- is_
touched_ from_ start PIf a touch contact that started over the widget is over it and it is enabled.- on_
disabled_ touch_ input PTouch contact started or ended over the widget, it is disabled and cursor capture allows it.- on_
disabled_ touch_ long_ press PSingle touch contact was made and held in place for a duration of time (default 500ms) on the widget and the widget is disabled.- on_
disabled_ touch_ tap PTouch tap on the widget and it is disabled.- on_
pre_ disabled_ touch_ input PPreviewon_disabled_touch_inputevent.- on_
pre_ disabled_ touch_ long_ press PPreviewon_disabled_touch_long_pressevent.- on_
pre_ disabled_ touch_ tap PPreviewon_disabled_touch_tapevent.- on_
pre_ touch_ cancel PPreviewon_touch_cancelevent.- on_
pre_ touch_ end PPreviewon_touch_endevent.- on_
pre_ touch_ enter PPreviewon_touch_enterevent.- on_
pre_ touch_ input PPreviewon_touch_inputevent.- on_
pre_ touch_ leave PPreviewon_touch_leaveevent.- on_
pre_ touch_ long_ press PPreviewon_touch_long_pressevent.- on_
pre_ touch_ move PPreviewon_touch_moveevent.- on_
pre_ touch_ start PPreviewon_touch_startevent.- on_
pre_ touch_ tap PPreviewon_touch_tapevent.- on_
pre_ touch_ transform PPreviewon_touch_transformevent.- on_
pre_ touched PPreviewon_touchedevent.- on_
touch_ cancel PTouch contact canceled over the widget, it is enabled and cursor capture allows it.- on_
touch_ end PTouch contact ended over the widget, it is enabled and cursor capture allows it.- on_
touch_ enter PTouch contact is now over the widget or a descendant and it is enabled.- on_
touch_ input PTouch contact started or ended over the widget, it is enabled and cursor capture allows it.- on_
touch_ leave PTouch contact is no longer over the widget or any descendant and it is enabled.- on_
touch_ long_ press PSingle touch contact was made and held in place for a duration of time (default 500ms) on the widget and the widget is enabled.- on_
touch_ move PTouch contact moved over the widget and cursor capture allows it.- on_
touch_ start PTouch contact started over the widget, it is enabled and cursor capture allows it.- on_
touch_ tap PTouch tap on the widget and it is enabled.- on_
touch_ transform PTouch gesture to translate, scale or rotate happened over this widget.- on_
touched PTouch contact entered or left the widget and descendants area and it is enabled.- touch_
active_ config PContextual configuration foris_touch_active.- touch_
transform PApplies transforms from touch gestures on the widget.