pub struct InteractionManager { /* private fields */ }Expand description
Stateful runtime that interprets raw pointer input and emits high-level
InteractionEvents.
§Lifecycle
- Create with
InteractionManager::neworInteractionManager::with_config. - Each frame, feed input via
update_pointer_move,update_pointer_down,update_pointer_up, orupdate_pointer_leave. - Call
drain_eventsto consume emitted events.
The manager borrows &mut MapState during each update call so it can
run pick queries and (optionally) mutate feature state.
Implementations§
Source§impl InteractionManager
impl InteractionManager
Sourcepub fn with_config(config: InteractionConfig) -> Self
pub fn with_config(config: InteractionConfig) -> Self
Create a new interaction manager with custom configuration.
Sourcepub fn config(&self) -> &InteractionConfig
pub fn config(&self) -> &InteractionConfig
Read-only access to the current configuration.
Sourcepub fn config_mut(&mut self) -> &mut InteractionConfig
pub fn config_mut(&mut self) -> &mut InteractionConfig
Mutable access to the configuration.
Sourcepub fn hovered(&self) -> Option<&FeatureStateId>
pub fn hovered(&self) -> Option<&FeatureStateId>
The feature identity that is currently hovered, if any.
Sourcepub fn selected(&self) -> Option<&FeatureStateId>
pub fn selected(&self) -> Option<&FeatureStateId>
The feature identity that is currently selected, if any.
Sourcepub fn cursor(&self) -> ScreenPoint
pub fn cursor(&self) -> ScreenPoint
Current logical cursor position.
Sourcepub fn is_dragging(&self) -> bool
pub fn is_dragging(&self) -> bool
Whether the current pointer sequence is being treated as a drag.
Sourcepub fn update_pointer_move(
&mut self,
map: &mut MapState,
x: f64,
y: f64,
time: f64,
pointer_kind: PointerKind,
modifiers: InteractionModifiers,
)
pub fn update_pointer_move( &mut self, map: &mut MapState, x: f64, y: f64, time: f64, pointer_kind: PointerKind, modifiers: InteractionModifiers, )
Feed a pointer-move event.
The manager runs a pick query at (x, y), diffs the result against
the previous frame, and emits MouseLeave / MouseEnter transitions
as needed. A MouseMove event is always emitted.
time is a monotonic timestamp in seconds provided by the host.
Sourcepub fn update_pointer_down(
&mut self,
map: &MapState,
x: f64,
y: f64,
time: f64,
button: InteractionButton,
pointer_kind: PointerKind,
modifiers: InteractionModifiers,
)
pub fn update_pointer_down( &mut self, map: &MapState, x: f64, y: f64, time: f64, button: InteractionButton, pointer_kind: PointerKind, modifiers: InteractionModifiers, )
Feed a pointer-down event.
Records the press position and timestamp for later click-vs-drag
classification. Emits a MouseDown event.
time is a monotonic timestamp in seconds provided by the host.
Sourcepub fn update_pointer_up(
&mut self,
map: &mut MapState,
x: f64,
y: f64,
time: f64,
button: InteractionButton,
pointer_kind: PointerKind,
modifiers: InteractionModifiers,
)
pub fn update_pointer_up( &mut self, map: &mut MapState, x: f64, y: f64, time: f64, button: InteractionButton, pointer_kind: PointerKind, modifiers: InteractionModifiers, )
Feed a pointer-up event.
Emits MouseUp unconditionally. If the pointer did not exceed the drag
threshold, also emits Click. If two Clicks occur within the
double-click window, also emits DoubleClick.
When auto_select_state is enabled and a Click is produced, the
manager updates the "selected" feature-state property.
time is a monotonic timestamp in seconds provided by the host.
Sourcepub fn update_pointer_leave(
&mut self,
map: &mut MapState,
pointer_kind: PointerKind,
modifiers: InteractionModifiers,
)
pub fn update_pointer_leave( &mut self, map: &mut MapState, pointer_kind: PointerKind, modifiers: InteractionModifiers, )
Notify the manager that the pointer has left the map viewport.
Emits MouseLeave for the current hover target and clears all
transient hover state.
Sourcepub fn drain_events(&mut self) -> Vec<InteractionEvent>
pub fn drain_events(&mut self) -> Vec<InteractionEvent>
Drain and return all pending interaction events.
This is the primary output interface. The host calls this once per
frame after feeding all input events and iterates the returned
Vec to dispatch application-level handlers.
Sourcepub fn pending_event_count(&self) -> usize
pub fn pending_event_count(&self) -> usize
Number of pending events not yet drained.