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§
- Capture
Info - Information about mouse and touch capture in a mouse or touch event argument.
- POINTER_
CAPTURE - Mouse and touch capture service.
- Pointer
Capture Args POINTER_CAPTURE_EVENTarguments.
Enums§
- Capture
Mode - Mouse and touch capture mode.
Statics§
- POINTER_
CAPTURE_ EVENT - Mouse and touch capture changed event.
Functions§
- capture_
pointer PCapture mouse and touch for the widget on press.- capture_
pointer_ on_ init PCapture mouse and touch for the widget on init.- on_
got_ pointer_ capture PWidget acquired mouse and touch capture.- on_
lost_ pointer_ capture PWidget lost mouse and touch capture.- on_
pointer_ capture_ changed PWidget acquired or lost mouse and touch capture.- on_
pre_ got_ pointer_ capture PPreviewon_got_pointer_captureevent.- on_
pre_ lost_ pointer_ capture PPreviewon_lost_pointer_captureevent.- on_
pre_ pointer_ capture_ changed PPreviewon_pointer_capture_changedevent.