/** * * Handle mouse-down events on the scroll thumb. Records * the mouse down point in _clickOffset. */ protected virtual void ThumbMouseDownHandler(Event e) { e.CancelAndStopPropagation(); DragManager.IsDragging = true; //Debug.Log("ThumbMouseDownHandler: " + e); MouseEvent me = (MouseEvent)e; var sm = SystemEventDispatcher.Instance; sm.AddEventListener(MouseEvent.MOUSE_MOVE, SystemMouseMoveHandler); sm.AddEventListener(MouseEvent.MOUSE_UP, SystemMouseUpHandler); _clickOffset = Thumb.GlobalToLocal(me.GlobalPosition); DispatchEvent(new TrackBaseEvent(TrackBaseEvent.THUMB_PRESS)); DispatchEvent(new FrameworkEvent(FrameworkEvent.CHANGE_START)); }
/** * * Capture mouse-move events anywhere on or off the stage. * First, we calculate the new value based on the new position * using calculateNewValue(). Then, we move the thumb to * the new value's position. Last, we set the value and * dispatch a "change" event if the value changes. */ protected virtual void SystemMouseMoveHandler(Event e) { if (null == Track) { return; } MouseEvent me = (MouseEvent)e; Point p = Track.GlobalToLocal(me.GlobalPosition); float newValue = PointToValue(p.X - _clickOffset.X, p.Y - _clickOffset.Y); newValue = NearestValidValue(newValue, SnapInterval); if (newValue != Value) { SetValue(newValue); DispatchEvent(new TrackBaseEvent(TrackBaseEvent.THUMB_DRAG)); DispatchEvent(new Event(Event.CHANGE)); } }