SceneTapEvent
Per-item event handlers, cursor and tooltip overrides.
Public types
| Kind | Name |
|---|---|
struct | SceneTapEvent — Click-style gesture envelope for scene items |
enum | DragMode — What a SceneView's on-canvas pointer drag does in empty space |
struct | SceneItemHandlerSet — Per-item event closures + cursor + tooltip + drop acceptance |
Public functions
SceneTapEvent
| Returns | Function |
|---|---|
| Constructors | |
Self | new(position_scene: Point, button: PointerButton, modifiers: Modifiers) |
SceneItemHandlerSet
| Returns | Function |
|---|---|
| Constructors | |
Self | new() |
| Methods | |
&mut Self | on_tap<F>(f: F) |
&mut Self | on_tap_event<F>(f: F) |
&mut Self | on_double_tap<F>(f: F) |
&mut Self | on_double_tap_event<F>(f: F) |
&mut Self | on_hover<F>(f: F) |
&mut Self | on_context_menu<F>(f: F) |
&mut Self | on_context_menu_event<F>(f: F) |
&mut Self | accept_tap_buttons(mask: ButtonMask) |
&mut Self | cursor(c: CursorIcon) |
&mut Self | tooltip(t: impl Into<LocalizedString>) |
&mut Self | accepts_drops(accepts: bool) |
Detailed description
SceneItemHandlerSet is the lightweight-tier counterpart to
widget-level HandlerSet.
It carries optional closures the SceneView
invokes when pointer / hover / context-menu events land on the
item, plus per-item cursor and tooltip overrides.
Apps attach handlers via Scene::set_item_handlers /
Scene::handlers_mut after add_item:
let id = scene.add_item(rect, Point::ZERO);
scene.handlers_mut(id).unwrap()
.on_tap(|_pt, ctx| ctx.send_intent(AppIntent::OpenCard))
.cursor(CursorIcon::Pointer)
.tooltip("Open card");
API reference
📖 Full rustdoc API for this module
pub struct SceneTapEvent
Import: use teksilo_scene::SceneTapEvent; — add teksilo-scene to [dependencies]: teksilo does not re-export it.
Click-style gesture envelope for scene items. Mirrors the
widget-tier teksilo_core::gesture::TapEvent but with the
position in scene coordinates instead of widget-local. Used
by the tap / double-tap / triple-tap / long-press / context-menu
handlers on SceneItemHandlerSet.
#[non_exhaustive] so future additions (e.g. tap count,
stylus pressure) can land without breaking match patterns.
#![allow(unused)] fn main() { pub struct SceneTapEvent { /* fields */ } }
Fields
position_scene:Point— Click position in scene coordinates. The SceneView's dispatch converts the raw screen-pixel pointer position through the view transform before populating this field, so handlers see the same frame their item's geometry is in.button:PointerButton— Which button finalised the gesture.modifiers:Modifiers— Modifier keys held at dispatch time.
Methods
pub fn new(position_scene: Point, button: PointerButton, modifiers: Modifiers) -> Self
Construct one by hand. Useful for tests; dispatch builds
these from the live pointer event in SceneView.
pub enum DragMode
Import: use teksilo_scene::DragMode; — add teksilo-scene to [dependencies]: teksilo does not re-export it.
What a SceneView's on-canvas pointer drag
does in empty space.
DragMode::NoDrag— nothing happens. Useful for embedded read-only diagrams.DragMode::ScrollHandDrag— left-click-drag pans the view. Item-level on-drag handlers are bypassed; the canvas grabs the gesture unconditionally.DragMode::RubberBand(default) — drag-on-empty-space creates a marquee that selects items inside on release. Drag-on-an-item dispatches to that item's drag handler if wired (the drag pipeline honoursIS_DRAGGABLEfor drag-to-move).
#![allow(unused)] fn main() { pub enum DragMode { /* variants */ } }
Variants
NoDrag— Empty-space drag is a no-op; useful for read-only embedded diagrams.ScrollHandDrag— Left-click-drag pans the viewport; item-level drag handlers are bypassed.RubberBand— Empty-space drag draws a selection marquee; item drag dispatches to the item's drag handler (respectingIS_DRAGGABLE). This is the default.
pub struct SceneItemHandlerSet
Import: use teksilo_scene::SceneItemHandlerSet; — add teksilo-scene to [dependencies]: teksilo does not re-export it.
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.
#![allow(unused)] fn main() { pub struct SceneItemHandlerSet { /* fields */ } }
Fields
on_tap:Option<SceneTapHandler>— Tap (single click). Stored as the richSceneTapEventform internally; the simplerSelf::on_tapsetter wrapsFn(Point, ...)callers in a shim that extractsevent.position_scene.on_double_tap:Option<SceneTapHandler>— 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<ItemHandler<bool>>— Hover transitions:boolistrueon enter,falseon leave.on_context_menu:Option<SceneTapHandler>— Right-click / OS-native context-menu trigger.accept_tap_buttons:ButtonMask— Which pointer buttons count as a "tap" / context-menu invocation. DefaultButtonMask::PRIMARYfor tap; the SECONDARY button always routes throughon_context_menuregardless of this mask. Items wanting middle-click-as-tap extend the mask:accept_tap_buttons(PRIMARY | MIDDLE). Mirrors widget-tieraccept_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 aLocalizedString(not an eagerly-resolvedString) so atr!(...)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.
Methods
pub fn new() -> Self
An empty handler set — every closure unset, no cursor or tooltip.
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.
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).
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.
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.
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.
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.
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.
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.
pub fn cursor(&mut self, c: CursorIcon) -> &mut Self
Override the cursor icon shown over this item.
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.
pub fn accepts_drops(&mut self, accepts: bool) -> &mut Self
Mark whether the item accepts dropped payloads.