Skip to main content

InteractionManager

Struct InteractionManager 

Source
pub struct InteractionManager { /* private fields */ }
Expand description

Stateful runtime that interprets raw pointer input and emits high-level InteractionEvents.

§Lifecycle

  1. Create with InteractionManager::new or InteractionManager::with_config.
  2. Each frame, feed input via update_pointer_move, update_pointer_down, update_pointer_up, or update_pointer_leave.
  3. Call drain_events to 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

Source

pub fn new() -> Self

Create a new interaction manager with default configuration.

Source

pub fn with_config(config: InteractionConfig) -> Self

Create a new interaction manager with custom configuration.

Source

pub fn config(&self) -> &InteractionConfig

Read-only access to the current configuration.

Source

pub fn config_mut(&mut self) -> &mut InteractionConfig

Mutable access to the configuration.

Source

pub fn hovered(&self) -> Option<&FeatureStateId>

The feature identity that is currently hovered, if any.

Source

pub fn selected(&self) -> Option<&FeatureStateId>

The feature identity that is currently selected, if any.

Source

pub fn cursor(&self) -> ScreenPoint

Current logical cursor position.

Source

pub fn is_dragging(&self) -> bool

Whether the current pointer sequence is being treated as a drag.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn pending_event_count(&self) -> usize

Number of pending events not yet drained.

Trait Implementations§

Source§

impl Debug for InteractionManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for InteractionManager

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.