the dragable DisplayObject to move according to mouse movements;
null indicates that events will just be translated to simulation coordinates
the SimView that the DisplayObject is in; or the SimView to use for translating to simulation coordinates when there is no DisplayObject
location of initial mouse event in simulation coordinates of view
location of 'drag point' on the
SimObject in body coordinates of the SimObject; this is where for example a spring
will be attached on the SimObject when dragging; will be null when no SimObject
was found
the EventHandler to send events to; will be null when a
DisplayObject should be dragged directly
Private dragthe DisplayObject currently being dragged.
Private dragthe offset between the dragable DisplayObject's initial position and the initial mouse click, in simulation coordinates.
Private dragThe SimObject being dragged (the SimObject being displayed by dragDispObj_) if no SimObject found, send the x, y coords of the click anyway, with simObj=null
Private drag_location of drag point in body coordinates of the SimObject; ignored when there is no SimObject
Private ehtrue when EventHandler is dragging a SimObject
Private loc_location of mouse event in SimView's simulation coords
Private view_the SimView to search for dragable objects
Called when a mouse move event occurs.
location of the event in screen coordinates
Called when a mouse down event occurs.
the modifier keys down during event
Static findFinds the nearest dragable DisplayObject to the starting location (using distance in screen coordinates), and creates a MouseTracker for dragging it. If no dragable DisplayObject is found, creates a MouseTracker which translates mouse events to simulation coordinates of the LabCanvas's focus view.
Searches all the SimView's of the LabCanvas, in front to back order. When a DisplayObject has no SimObject, then regard it as an 'opaque' object and immediately accept it as the target if mouse is inside; or ignore it entirely if mouse is outside. We search from front to back in visual order, so that objects that are visually 'on top' are checked first.
the LabCanvas to process events for
mouse down location in LabCanvas screen coords
the EventHandler to send mouse events to, or null
the MouseTracker to use for processing mouse events,
or null if MouseTracking is not possible
Generated using TypeDoc
Processes mouse events to either (1) directly move a DisplayObject or (2) forward events to an EventHandler.
(1) MouseTracker moves the DisplayObject directly when:
No EventHandler is specified.
dragDispObjdoes not have a SimObject. Examples include DisplayClock and EnergyBarGraph.dragDispObjhas a SimObject but it is not recognized by the EventHandler. An EventHandler indicates that it doesn't recognize a SimObject by returningfalsefrom EventHandler.startDrag. An example scenario is a dragable marker object which the user can position as desired.(2) Events are sent to the EventHandler when:
dragDispObjhas a SimObject which is recognized by the EventHandler. An EventHandler indicates that it recognizes a SimObject by returningtruefrom EventHandler.startDrag. In this case, events are translated to simulation coordinates for the SimView that the DisplayObject is in.dragDispObjisnull. In this case, events are translated to simulation coordinates of the specified SimView.See Mouse Events in SimController.
TO DO what to do when there are multiple SimObjects, as with DisplayPath?
TO DO Make a unit test; especially for findNearestDragable. Note that it is possible to make synthetic events for testing in Javascript.