pub struct MouseTracker { /* private fields */ }Expand description
Tracks the relationship between mouse devices and annotations, and triggers mouse events and cursor changes accordingly.
The MouseTracker tracks the relationship between mouse devices and
MouseTrackerAnnotation, notified by update_with_event and
update_all_devices. At every update, MouseTracker triggers the
following changes if applicable:
- Dispatches mouse-related pointer events (pointer enter, hover, and exit).
- Changes mouse cursors.
- Notifies when
mouse_is_connectedchanges.
This class is a ChangeNotifier that notifies its listeners if the value of
mouse_is_connected changes.
An instance of MouseTracker is owned by the global singleton
RendererBinding.
Implementations§
Source§impl MouseTracker
impl MouseTracker
Sourcepub fn new(
app: &mut App,
hit_test_in_view: MouseTrackerHitTest,
) -> Handle<MouseTracker>
pub fn new( app: &mut App, hit_test_in_view: MouseTrackerHitTest, ) -> Handle<MouseTracker>
Create a mouse tracker.
The hit_test_in_view is used to find the render objects on a given
position in the specific view. It is typically provided by the
RendererBinding.
Sourcepub fn dispose(self: Handle<Self>, app: &mut App)
pub fn dispose(self: Handle<Self>, app: &mut App)
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded.
Sourcepub fn mouse_is_connected(self: Handle<Self>, app: &App) -> bool
pub fn mouse_is_connected(self: Handle<Self>, app: &App) -> bool
Whether or not at least one mouse is connected and has produced events.
Sourcepub fn update_with_event(
self: Handle<Self>,
app: &mut App,
event: &PointerEvent,
hit_test_result: Option<&HitTestResult>,
)
pub fn update_with_event( self: Handle<Self>, app: &mut App, event: &PointerEvent, hit_test_result: Option<&HitTestResult>, )
Perform a device update for one device according to the given new event.
The update_with_event is typically called by the RendererBinding during
the handler of a pointer event. All pointer events should call this
method, and let MouseTracker filter which to react to.
The hit_test_result serves as an optional optimization, and is the hit
test result already performed by the RendererBinding for other gestures.
It can be None, but when it’s not None, it should be identical to the
result from directly calling hit_test_in_view given in the constructor
(which means that it must not use the cached result for
PointerEvent::Move).
The update_with_event is one of the two ways of updating mouse
states, the other one being update_all_devices.
Sourcepub fn update_all_devices(self: Handle<Self>, app: &mut App)
pub fn update_all_devices(self: Handle<Self>, app: &mut App)
Perform a device update for all devices.
This is called by the RendererBinding after a frame, since the render
tree might have changed under a still mouse.
The update_all_devices is one of the two ways of updating mouse
states, the other one being update_with_event.
Sourcepub fn debug_device_active_cursor(
self: Handle<Self>,
app: &App,
device: i64,
) -> Option<MouseCursorRef>
pub fn debug_device_active_cursor( self: Handle<Self>, app: &App, device: i64, ) -> Option<MouseCursorRef>
Returns the active mouse cursor for a device.
The return value is the last MouseCursorRef activated onto this
device, even if the activation failed.
This function is only active in debug mode: in release it returns None.
Trait Implementations§
Source§impl ChangeNotifier for MouseTracker
impl ChangeNotifier for MouseTracker
fn change_notifier_data(&self) -> &ChangeNotifierData
fn change_notifier_data_mut(&mut self) -> &mut ChangeNotifierData
Source§fn will_add_listener(self: Handle<Self>, app: &mut App)
fn will_add_listener(self: Handle<Self>, app: &mut App)
addListener that
work before super.addListener go here.Source§fn did_remove_listener(self: Handle<Self>, app: &mut App)
fn did_remove_listener(self: Handle<Self>, app: &mut App)
removeListener that
work after super.removeListener go here.