Mouse Events

Event Routing

Any SceneNode can respond to mouse events, either directly or indirectly. Ascend implements a routed event system, by which events are routed up through ancestors or down through descendants until handled. The routing behaviors of events are similar to those of WPF in that there are three types:
  • Tunneling: Events are invoked on the highest-level ancestor SceneNode first, and are then routed down the descendant chain to the source SceneNode
  • Bubbling: Events are invoked on the source SceneNode first, and are then routed up the ancestor chain to the highest-level ancestor SceneNode
  • Direct: Events are invoked only on the source SceneNode
Similarly to WPF, Ascend always routes non-direct events in order of tunneling, then bubbling. It is important to note that events are not supported on Bones or Armatures, but events are routed through them.

For more information tunneling and bubbling event routing, see the MSDN article WPF Input Events.

Supported Events

The table below describes the events that are supported on SceneNodes. With the exception of MouseEnter and MouseLeave, which are direct events, each item describes a bubbling event with its tunneling counterpart given by prepending Preview to the event name.

Event Description
Preview/MouseDoubleClickwhite_space.png Occurs when a mouse is clicked two or more times over a SceneNode
Preview/MouseDown Occurs when a mouse button is pressed over a SceneNode
Preview/MouseUp Occurs when a mouse button is released over a SceneNode
Preview/MouseMove Occurs when a mouse is moved while over a SceneNode
Preview/MouseWheel Occurs when a mouse wheel is moved while over a SceneNode
MouseEnter Occurs when a mouse moves onto a ModelSceneNode or AnimatedSceneNode
MouseLeave Occurs when a mouse moves off of a ModelSceneNode or AnimatedSceneNode

Event Args

When a mouse event is handled, the handler is supplied with SceneNodeMouseEventArgs which, in addition to typical mouse event information, provides the following properties:
  • SceneViewer: The SceneViewer3D that contains the hit SceneNode
  • Source: The SceneNode that initiated the event
  • HitTestResult: The System.Windows.Media.Media3D.RayHitTestResult associated with the event
  • Handled: A boolean specifying whether the event was handled. If set to true, further handlers will not be triggered.

 

Last edited May 1, 2014 at 5:54 PM by menehune23, version 23

Comments

No comments yet.