Expand description
Pointer capture service, properties, events and other types.
Pointer events target to the topmost widget under the pointer by default, the POINTER_CAPTURE
service
can be used to capture the pointer for a widget so that it remains the target for pointer events. The
capture_pointer
property can be used to automatically capture the pointer when pressed.
use zng::prelude::*;
Wgt! {
zng::pointer_capture::capture_pointer = true;
zng::pointer_capture::on_got_pointer_capture = hn!(|_| {
println!("got capture");
});
zng::pointer_capture::on_lost_pointer_capture = hn!(|_| {
println!("lost capture");
});
when *#gesture::is_cap_hovered {
widget::background_color = colors::GREEN;
}
widget::background_color = colors::RED;
layout::size = 80;
}
The example above declares a widget is green when hovered or is holding the pointer capture, the widget also logs
when it gets and loses the capture. Note that the gesture::is_cap_hovered
state is not the same as gesture::is_hovered
,
if changed to the second the example will not be green when not hovering, even though the widget still holds the capture, pointer
capture changes the target of pointer events, but it does not mask the fact that the pointer is not actually over the widget.
§Full API
See zng_ext_input::pointer_capture
and zng_wgt_input::pointer_capture
for the full pointer capture API.
Structs§
- Information about mouse and touch capture in a mouse or touch event argument.
- Mouse and touch capture service.
POINTER_CAPTURE_EVENT
arguments.
Enums§
- Mouse and touch capture mode.
Statics§
- Mouse and touch capture changed event.
Functions§
P
Capture mouse and touch for the widget on press.P
Capture mouse and touch for the widget on init.P
Widget acquired mouse and touch capture.P
Widget lost mouse and touch capture.P
Widget acquired or lost mouse and touch capture.P
Previewon_got_pointer_capture
event.P
Previewon_lost_pointer_capture
event.P
Previewon_pointer_capture_changed
event.