pub trait MouseCursorSession {
// Required methods
fn cursor(&self) -> MouseCursorRef;
fn device(&self) -> i64;
fn activate(&mut self, platform: &dyn Platform, view: ViewId);
fn dispose(&mut self);
}Expand description
Manages the duration that a pointing device should display a specific mouse cursor.
While MouseCursor classes describe the kind of cursors, MouseCursorSession
classes represent a continuous use of the cursor on a pointing device. The
MouseCursorSession classes can be stateful. For example, a cursor that
needs to load resources might want to try a fallback cursor first, and switch
to the target cursor when the resources are loaded.
A MouseCursorSession has the following lifecycle:
- When a pointing device should start displaying a cursor,
MouseTrackercreates a session by callingMouseCursor::create_sessionon the target cursor, and stores it in a table associated with the device. MouseTrackerthen immediately calls the session’sactivate, where the session should fetch resources and make system calls.- When the pointing device should start displaying another cursor,
MouseTrackercallsdisposeon this session. Afterdispose, this session will no longer be used in the future.
Required Methods§
Sourcefn cursor(&self) -> MouseCursorRef
fn cursor(&self) -> MouseCursorRef
The cursor that created this session.
Sourcefn activate(&mut self, platform: &dyn Platform, view: ViewId)
fn activate(&mut self, platform: &dyn Platform, view: ViewId)
Override this method to do the work of changing the cursor of the device.
Called right after this session is created.
This method has full control over the cursor until the dispose call,
and can make system calls to change the pointer cursor as many times as
necessary (usually through the system cursor request of the host of view,
the one the device is on, which platform finds; a session that changes the
cursor later keeps it).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".