override protected void TrackMouseDownHandler(Event e) { MouseEvent me = (MouseEvent) e; // which would push this enabled check into the child/skin components if (!Enabled) return; //Debug.Log("TrackMouseDownHandler: " + this); // Make sure we finish any running page animation before starting // a new one. //stopAnimation(); // Cache original event location for use on later repeating events _trackPosition = Track.GlobalToLocal(me.GlobalPosition); // If the user shift-clicks on the track, then offset the event coordinates so // that the thumb ends up centered under the mouse. if (me.Shift) { float thumbW = (null != Thumb) ? Thumb.Width /*Thumb.getLayoutBoundsWidth()*/ : 0; float thumbH = (null != Thumb) ? Thumb.Height /*Thumb.getLayoutBoundsHeight()*/ : 0; _trackPosition.X -= (thumbW / 2); _trackPosition.Y -= (thumbH / 2); } float newScrollValue = PointToValue(_trackPosition.X, _trackPosition.Y); //Debug.Log("newScrollValue: " + newScrollValue); _trackScrollDown = (newScrollValue > Value); if (me.Shift) { //Debug.Log("slideDuration: " + GetStyle("slideDuration")); //Debug.Log("smoothScrolling: " + GetStyle("smoothScrolling")); // shift-click positions jumps to the clicked location instead // of incrementally paging float slideDuration = (float)GetStyle("slideDuration"); float adjustedValue = NearestValidValue(newScrollValue, SnapInterval); if ((bool)GetStyle("smoothScrolling") && slideDuration != 0 && (Maximum - Minimum) != 0) { DispatchEvent(new FrameworkEvent(FrameworkEvent.CHANGE_START)); //// Animate the shift-click operation //startAnimation(slideDuration * // (Math.abs(value - newScrollValue) / (maximum - minimum)), // adjustedValue, deceleratingSineEaser); //animatingOnce = true; } else { SetValue(adjustedValue); DispatchEvent(new Event(Event.CHANGE)); } return; } DispatchEvent(new FrameworkEvent(FrameworkEvent.CHANGE_START)); // Assume we're repeating unless user releases //animatingOnce = false; ChangeValueByPage(_trackScrollDown); _trackScrolling = true; // Add event handlers for drag and up events var sm = SystemEventDispatcher.Instance; sm.AddEventListener(MouseEvent.MOUSE_MOVE, TrackMouseMoveHandler, EventPhase.Capture | EventPhase.Target); sm.AddEventListener(MouseEvent.MOUSE_UP, TrackMouseUpHandler, EventPhase.Capture | EventPhase.Target); sm.AddEventListener(MouseEvent.MOUSE_LEAVE, TrackMouseUpHandler); if (null == _trackScrollTimer) { _trackScrollTimer = new Timer((float) GetStyle("repeatDelay"), 1); _trackScrollTimer.AddEventListener(Timer.TICK, TrackScrollTimerHandler); } else { // Note that this behavior, resetting the initial delay, differs // from Flex3 but is more consistent with general application // scrollbar behavior _trackScrollTimer.Delay = (float) GetStyle("repeatDelay"); _trackScrollTimer.RepeatCount = 1; } _trackScrollTimer.Start(); }
/** * */ private void StartTimer() { _autoRepeatTimer = new Timer((float)GetStyle("repeatDelay")); _autoRepeatTimer.AddEventListener(Timer.TICK, AutoRepeatTimerDelayHandler); _autoRepeatTimer.Start(); }