private void MoveAreaMouseDownHandler(Event e) { //Debug.Log("Mouse down: " + e.Target); //if (e.Target != MoveArea) // return; //Debug.Log("MoveAreaMouseDownHandler: " + e.Target); // Only allow dragging of pop-upped windows if (Enabled && IsPopUp) { e.CancelAndStopPropagation(); // Calculate the mouse's offset in the window //offsetX = event.stageX - x; //offsetY = event.stageY - y; BringToFront(); MouseEvent me = (MouseEvent) e; _offset = me.GlobalPosition.Subtract(Transform.Position); var sm = SystemEventDispatcher.Instance; sm.AddEventListener(MouseEvent.MOUSE_MOVE, MoveAreaMouseMoveHandler, EventPhase.CaptureAndTarget); sm.AddEventListener(MouseEvent.MOUSE_UP, MoveAreaMouseUpHandler, EventPhase.CaptureAndTarget); _cursorId = CursorManager.Instance.SetCursor(CursorType.Move); } }
//private readonly Point _retVal = new Point(); public object Interpolate(float fraction, object startValue, object endValue) { _startValue = (Point)startValue; _endValue = (Point)endValue; // NOTE: Beware! // You cannot use _retVal with reference types! // That is because the first time the _retVal is being returned from this interpolator, it Bounds of the target object start referencing it // The next moment, we are changing values here (on the same object), and when "applying" the new values to the object, // Equals returns true because those values are already there (it's the same Rectangle), so nothing happens //_retVal.X = _startValue.X + (_endValue.X - _startValue.X) * fraction; //_retVal.Y = _startValue.X + (_endValue.X - _startValue.X) * fraction; //return _retVal; return new Point(_startValue.X + (_endValue.X - _startValue.X) * fraction, _startValue.Y + (_endValue.Y - _startValue.Y) * fraction); }
private void SystemMouseUpSomewhereHandler(Event e) { //Debug.Log("SystemMouseUpSomewhereHandler"); //var sm = SystemEventDispatcher.Instance; var dispatcher = MouseEventDispatcher.Instance; dispatcher.RemoveEventListener(MouseEvent.MOUSE_UP, SystemMouseUpSomewhereHandler, EventPhase.CaptureAndTarget); //Debug.Log("e.Target: " + e.Target); var dlm = (DisplayListMember)e.Target; // If we got a mouse down followed by a mouse up on a different target in the skin, // we want to dispatch a click event. if (_mouseDownTarget != e.Target && e is MouseEvent && Contains(dlm)) { MouseEvent mEvent = e as MouseEvent; // Convert the mouse coordinates from the target to the TrackBase Point mousePoint = new Point(mEvent.LocalPosition.X, mEvent.LocalPosition.Y); mousePoint = GlobalToLocal(dlm.LocalToGlobal(mousePoint)); var me2 = new MouseEvent(MouseEvent.CLICK, mEvent.Bubbles, mEvent.Cancelable) { LocalPosition = new Point(mousePoint.X, mousePoint.Y), RelatedObject = null, Control = mEvent.Control, Shift = mEvent.Shift, Alt = mEvent.Alt, ButtonDown = mEvent.ButtonDown, CurrentEvent = mEvent.CurrentEvent }; DispatchEvent(me2); } _mouseDownTarget = null; }
/** * * 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)); }
/// <summary> /// The place where the developer could implement the custom logic before the child addition /// </summary> /// <param name="child"></param> //protected virtual void AddingChild(DisplayListMember child) { } /// <summary> /// The place where the developer could implement the custom logic after the child removal /// </summary> /// <param name="child"></param> // ReSharper disable UnusedParameter.Global // ReSharper disable VirtualMemberNeverOverriden.Global //protected virtual void ChildAdded(DisplayListMember child) { } // ReSharper restore VirtualMemberNeverOverriden.Global // ReSharper restore UnusedParameter.Global /// <summary> /// The place where the developer could implement the custom logic before the child removal /// </summary> /// <param name="child"></param> // ReSharper disable UnusedParameter.Global // ReSharper disable VirtualMemberNeverOverriden.Global //protected virtual void RemovingChild(DisplayListMember child) { } // ReSharper restore VirtualMemberNeverOverriden.Global // ReSharper restore UnusedParameter.Global /// <summary> /// The place where the developer could implement the custom logic after the child removal /// </summary> /// <param name="child"></param> // ReSharper disable VirtualMemberNeverOverriden.Global // ReSharper disable UnusedParameter.Global //protected virtual void ChildRemoved(DisplayListMember child) { } // ReSharper restore UnusedParameter.Global // ReSharper restore VirtualMemberNeverOverriden.Global #endregion #region ContainsPoint public override bool ContainsPoint(Point point, bool recursive) { if (base.ContainsPoint(point, recursive)) return true; if (recursive) { return _children.Exists(delegate(DisplayListMember child) { return child.ContainsPoint(point, true); }); } return false; }