Expand description
This module defines a stateful set of interaction events driven by the PointerInput stream
and the hover state of each Pointer.
§Usage
To receive events from this module, you must use an Observer or MessageReader with PointerEvents.
The simplest example, registering a callback when an entity is hovered over by a pointer, looks like this:
world.spawn_empty()
.observe(|event: On<PointerOver>| {
println!("I am being hovered over");
});Observers give us three important properties:
- They allow for attaching event handlers to specific entities,
- they allow events to bubble up the entity hierarchy,
- and they allow events of different types to be called in a specific order.
The order in which interaction events are received is extremely important, and you can read more
about it on the docs for the dispatcher system: pointer_events. This system runs in
PreUpdate in PickingSystems::Hover. All pointer-event
observers resolve during the sync point between pointer_events and
update_interactions.
§Events Types
The events this module defines fall into a few broad categories:
- Hovering and movement:
PointerOver,PointerEnter,PointerMove,PointerLeave, andPointerOut. - Clicking and pressing:
PointerPress,PointerRelease, andPointerClick. - Dragging and dropping:
PointerDragStart,PointerDrag,PointerDragEnd,PointerDragEnter,PointerDragOver,PointerDragDrop,PointerDragLeave.
These events each have a Pointer field, which contains information about the pointer.
Structs§
- Drag
Entry - Dragging state.
- Hovered
Entity Ancestors - A cache map containing the ancestry of hovered entities
- Picking
Message Writers - A helper system param for accessing the picking event writers.
- Pointer
- Stores the common data needed for all pointer events.
- Pointer
Button State - An entry in the cache that drives the
pointer_eventssystem, storing additional data about pointer button presses. - Pointer
Cancel - Fires when a pointer is canceled, and its current interaction state is dropped.
- Pointer
Click - Fires when a pointer sends a pointer pressed event followed by a pointer released event, with the same target entity for both events.
- Pointer
Drag - Fires while the target entity is being dragged.
- Pointer
Drag Drop - Fires when a pointer drops the
droppedentity onto the target entity. - Pointer
Drag End - Fires when a pointer is dragging the target entity and a pointer released event is received.
- Pointer
Drag Enter - Fires when a pointer dragging the
draggedentity enters the target entity - Pointer
Drag Leave - Fires when a pointer dragging the
draggedentity leaves the target entity. - Pointer
Drag Over - Fires while the
draggedentity is being dragged over the target entity. - Pointer
Drag Start - Fires when the target entity receives a pointer pressed event followed by a pointer move event.
- Pointer
Enter - Fires when a pointer crosses into the bounds of a target entity.
Unlike
PointerOver, this event bubbles up through a subset of the target entity’s ancestors (traversed via theChildOfrelationship). - Pointer
Leave - Fires when a pointer crosses out of the bounds of a target entity.
Unlike
PointerOut, this event bubbles up through a subset of the target entity’s ancestors (traversed via theChildOfrelationship). - Pointer
Move - Fires while a pointer is moving over the target entity.
- Pointer
Out - Fires when a pointer crosses out of the bounds of a target entity.
Unlike
PointerLeave, this event bubbles up to all of the target entity’s ancestors (traversed via theChildOfrelationship) without restriction. Refer topointer_eventsfor more information on how these events are triggered. Refer toPointerTraversalfor howPointerevents are propagated. - Pointer
Over - Fires when a pointer crosses into the bounds of a target entity.
Unlike
PointerEnter, this event bubbles up to all of the target entity’s ancestors (traversed via theChildOfrelationship) without restriction. Refer topointer_eventsfor more information on how these events are triggered. Refer toPointerTraversalfor howPointerevents are propagated. - Pointer
Press - Fires when a pointer button is pressed over the target entity.
- Pointer
Release - Fires when a pointer button is released over the target entity.
- Pointer
Scroll - Fires while a pointer is scrolling over the target entity.
- Pointer
State - State for all pointers.
- Pointer
Traversal - A traversal query (i.e. it implements
Traversal) intended for use withPointerevents. - Pointer
Traversal Item - Automatically generated
WorldQueryitem type forPointerTraversal, returned when iterating over query results.
Traits§
- Pointer
Event - An
EntityEventthat contains aPointer.
Functions§
- pointer_
events - Dispatches interaction events to the target entities.