Skip to main content

SceneItemHandlerSet

Struct SceneItemHandlerSet 

Source
pub struct SceneItemHandlerSet {
    pub on_tap: Option<Rc<dyn Fn(&SceneTapEvent, &mut EventContext<'_>)>>,
    pub on_double_tap: Option<Rc<dyn Fn(&SceneTapEvent, &mut EventContext<'_>)>>,
    pub on_hover: Option<Rc<dyn Fn(bool, &mut EventContext<'_>)>>,
    pub on_context_menu: Option<Rc<dyn Fn(&SceneTapEvent, &mut EventContext<'_>)>>,
    pub accept_tap_buttons: ButtonMask,
    pub cursor: Option<CursorIcon>,
    pub tooltip: Option<LocalizedString>,
    pub accepts_drops: bool,
}
Expand description

Per-item event closures + cursor + tooltip + drop acceptance.

Closures are stored as Rc<dyn Fn> so cloning the handler set is cheap; the SceneView clones into its dispatch path.

Fields§

§on_tap: Option<Rc<dyn Fn(&SceneTapEvent, &mut EventContext<'_>)>>

Tap (single click). Stored as the rich SceneTapEvent form internally; the simpler Self::on_tap setter wraps Fn(Point, ...) callers in a shim that extracts event.position_scene.

§on_double_tap: Option<Rc<dyn Fn(&SceneTapEvent, &mut EventContext<'_>)>>

Double-tap. Storage only — the SceneView’s dispatch site doesn’t synthesise double-tap recognition yet; this field stays unset-on-fire until a future unit wires the recognizer in. Treat as a forward-declared slot.

§on_hover: Option<Rc<dyn Fn(bool, &mut EventContext<'_>)>>

Hover transitions: bool is true on enter, false on leave.

§on_context_menu: Option<Rc<dyn Fn(&SceneTapEvent, &mut EventContext<'_>)>>

Right-click / OS-native context-menu trigger.

§accept_tap_buttons: ButtonMask

Which pointer buttons count as a “tap” / context-menu invocation. Default [ButtonMask::PRIMARY] for tap; the SECONDARY button always routes through on_context_menu regardless of this mask. Items wanting middle-click-as-tap extend the mask: accept_tap_buttons(PRIMARY | MIDDLE). Mirrors widget-tier accept_tap_buttons(...).

§cursor: Option<CursorIcon>

Cursor icon shown while the pointer is over this item. Overrides the SceneView default.

§tooltip: Option<LocalizedString>

Tooltip body for this item. Kept as a LocalizedString (not an eagerly-resolved String) so a tr!(...) source follows the active locale — the SceneView resolves it against the current locale at show time. The SceneView’s hover machinery surfaces it as a point-anchored overlay through the standard overlay manager.

§accepts_drops: bool

Whether the item accepts dropped payloads.

Implementations§

Source§

impl SceneItemHandlerSet

Source

pub fn new() -> Self

An empty handler set — every closure unset, no cursor or tooltip.

Source

pub fn on_tap<F>(&mut self, f: F) -> &mut Self
where F: Fn(Point, &mut EventContext<'_>) + 'static,

Register a tap callback. Simpler Fn(Point, &mut ctx) signature for callers that only need the click position; internally wraps in a shim that extracts event.position_scene. For modifier-aware handlers (Shift- click selection, Ctrl-click toggle, etc.) use Self::on_tap_event which exposes the full SceneTapEvent.

Source

pub fn on_tap_event<F>(&mut self, f: F) -> &mut Self
where F: Fn(&SceneTapEvent, &mut EventContext<'_>) + 'static,

Register a tap callback that receives the full SceneTapEvent — scene-coord position, button, modifiers. Use for modifier-aware patterns (Shift+click extends selection, Ctrl+click toggles, middle-click handlers once paired with accept_tap_buttons).

Source

pub fn on_double_tap<F>(&mut self, f: F) -> &mut Self
where F: Fn(Point, &mut EventContext<'_>) + 'static,

Register a double-tap callback (Point-only shim — see Self::on_tap). Not wired yet: the SceneView’s dispatch doesn’t recognise double-tap; the field is stored but never fired. A future unit wires the recognizer.

Source

pub fn on_double_tap_event<F>(&mut self, f: F) -> &mut Self
where F: Fn(&SceneTapEvent, &mut EventContext<'_>) + 'static,

Rich-event variant of Self::on_double_tap.

Source

pub fn on_hover<F>(&mut self, f: F) -> &mut Self
where F: Fn(bool, &mut EventContext<'_>) + 'static,

Register a hover callback. Receives true on enter, false on leave.

Source

pub fn on_context_menu<F>(&mut self, f: F) -> &mut Self
where F: Fn(Point, &mut EventContext<'_>) + 'static,

Register a context-menu callback (right-click). Point-only shim; see Self::on_context_menu_event for the rich variant.

Source

pub fn on_context_menu_event<F>(&mut self, f: F) -> &mut Self
where F: Fn(&SceneTapEvent, &mut EventContext<'_>) + 'static,

Rich-event variant of Self::on_context_menu.

Source

pub fn accept_tap_buttons(&mut self, mask: ButtonMask) -> &mut Self

Mask of pointer buttons that should be treated as a tap for this item. Default [ButtonMask::PRIMARY]. Right-click (SECONDARY) always routes through on_context_menu regardless of this mask.

Source

pub fn cursor(&mut self, c: CursorIcon) -> &mut Self

Override the cursor icon shown over this item.

Source

pub fn tooltip(&mut self, t: impl Into<LocalizedString>) -> &mut Self

Set a tooltip. Accepts anything convertible into [LocalizedString] — most commonly tr!(...) for translated copy or lit!(...) for fixed text. Stored unresolved; the SceneView resolves it against the active locale when the tooltip is shown, so a tr!(...) source tracks locale changes.

Source

pub fn accepts_drops(&mut self, accepts: bool) -> &mut Self

Mark whether the item accepts dropped payloads.

Trait Implementations§

Source§

impl Clone for SceneItemHandlerSet

Source§

fn clone(&self) -> SceneItemHandlerSet

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SceneItemHandlerSet

Source§

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

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

impl Default for SceneItemHandlerSet

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> NoneValue for T
where T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more