Esempio n. 1
0
        internal static void BuildAndDispatchMouseEvent(EventDispatcher dispatcher, DisplayListMember targetComponent, string type, Point position, Event unityEvent)
        {
            //Debug.Log("BuildAndDispatchMouseEvent");

            if (null == dispatcher)
                throw new Exception("dispatcher cannot be null");

            if (null == targetComponent)
                throw new Exception("targetComponent cannot be null");

            if (!dispatcher.HasEventListener(type) && !targetComponent.HasBubblingEventListener(type)) // optimization
                return; // don't bother to build an event

            //Debug.Log("unityEvent: " + unityEvent);
            //var ue = unityEvent ?? Event.current;
            //Debug.Log("ue: " + ue);
            //Debug.Log("ue.button: " + ue.button);

            /**
             * 1) InvalidateDrawingList the event
             * */
            MouseEvent me = new MouseEvent(type)
                                {
                                    Target = targetComponent,
                                    CurrentEvent = unityEvent,
                                    GlobalPosition = position,
                                    LocalPosition = targetComponent.GlobalToLocal(position)
                                };

            if (null != MouseProcessor.MouseDownEvent)
            {
                // this is not a mouse move event, but rather a mouse drag, because MouseProcessor holds the reference to a mousedown event
                me.ButtonDown = MouseProcessor.MouseDownEvent.button == 0;
                me.RightButtonDown = MouseProcessor.MouseDownEvent.button == 1;
                me.MiddleButtonDown = MouseProcessor.MouseDownEvent.button == 2;
            }

            /**
             * 2) Dispatch from manager
             * */
            dispatcher.DispatchEvent(me);

            /**
             * 3) If not canceled, dispatch from component
             * */
            if (!me.Canceled)
            {
                me.Bubbles = true; // added 28.1.2012.
                targetComponent.DispatchEvent(me);
            }
        }
Esempio n. 2
0
        /**
	     *  Initiates a drag and drop operation.
	     *
	     *  Param: dragInitiator IUIComponent that specifies the component initiating
	     *  the drag.
	     *
	     *  Param: dragSource DragSource object that contains the data
	     *  being dragged.
	     *
	     *  Param: mouseEvent The MouseEvent that contains the mouse information
	     *  for the start of the drag.
	     *
	     *  Param: dragImage The image to drag. This argument is optional.
	     *  If omitted, a standard drag rectangle is used during the drag and
	     *  drop operation. If you specify an image, you must explicitly set a 
	     *  height and width of the image or else it will not appear.
	     *
	     *  Param: xOffset Number that specifies the x offset, in pixels, for the
	     *  <code>dragImage</code>. This argument is optional. If omitted, the drag proxy
	     *  is shown at the upper-left corner of the drag initiator. The offset is expressed
	     *  in pixels from the left edge of the drag proxy to the left edge of the drag
	     *  initiator, and is usually a negative number.
	     *
	     *  Param: yOffset Number that specifies the y offset, in pixels, for the
	     *  <code>dragImage</code>. This argument is optional. If omitted, the drag proxy
	     *  is shown at the upper-left corner of the drag initiator. The offset is expressed
	     *  in pixels from the top edge of the drag proxy to the top edge of the drag
	     *  initiator, and is usually a negative number.
	     *
	     *  Param: imageAlpha Number that specifies the alpha value used for the
	     *  drag image. This argument is optional. If omitted, the default alpha
	     *  value is 0.5. A value of 0.0 indicates that the image is transparent;
	     *  a value of 1.0 indicates it is fully opaque. 
             *
             *  Param: allowMove Indicates if a drop target is allowed to move the dragged data.
	     *  
	     */
        
        /// <summary>
        /// Starts a drag and drop operation
        /// </summary>
        /// <param name="dragInitiator"></param>
        /// <param name="dragSource"></param>
        /// <param name="mouseEvent"></param>
        /// <param name="dragImage"></param>
        /// <param name="xOffset"></param>
        /// <param name="yOffset"></param>
        /// <param name="imageAlpha"></param>
        /// <param name="allowMove"></param>
        /// <param name="options"></param>
        public static void DoDrag(Component dragInitiator, DragSource dragSource, MouseEvent mouseEvent, Component dragImage, float xOffset, float yOffset, float imageAlpha, bool allowMove, params DragOption[] options)
        {
#if DEBUG
            if (DebugMode)
                Debug.Log("DragDropManager.DoDrag: " + dragInitiator);
#endif
            _dragInitiator = dragInitiator;
            _dragSource = dragSource;
            _mouseEvent = mouseEvent;
            _dragImage = dragImage;
            _imageAlpha = imageAlpha;
            _allowMove = allowMove;

            ApplyOptions(options);

            /**
             * 20130307
             * Found some glitches regarding the starting the new drag operation while the previous one hasn't been finished yet
             * Since I was dealing with a single proxy instance since, some of the old (custom) proxies were stale, e.g. never removed when the tween finished
             * Now I added the line to a tween callback which destroys the animation target
             * */
            _proxy = dragImage ?? new DragProxy();

            DragProxy.Proxify(_proxy);

            _xOffset = xOffset;
            _yOffset = yOffset;
            
            DragDropStage.Instance.AddChild(_proxy); // TODO: cleanup after the drag operaion

            var dragInitiatorGlobalBounds = dragInitiator.Parent.LocalToGlobal(dragInitiator.Position);

            _proxy.X = dragInitiatorGlobalBounds.X;
            _proxy.Y = dragInitiatorGlobalBounds.Y;
            //_proxy.Bounds = (Rectangle)dragInitiator.Transform.GlobalBounds.Clone();
            _proxy.Visible = _proxyShouldBeVisible;
            _proxy.Alpha = imageAlpha;

            Offset = dragInitiatorGlobalBounds.Subtract(mouseEvent.GlobalPosition);
            
            if (_feedbackShouldBeVisible)
                ChangeCursorTo(CursorType.RejectDrop);

            /**
             * Subscribe to drag and mouse up events on system manager
             * */
            SystemEventDispatcher.Instance.AddEventListener(MouseEvent.MOUSE_DRAG, OnMouseDrag);
            SystemEventDispatcher.Instance.AddEventListener(MouseEvent.MOUSE_UP, OnMouseUp);

            //DragEvent dragStartEvent = BuildEvent(DragEvent.DRAG_START);
            //_dragInitiator.DispatchEvent(dragStartEvent);
        }
Esempio n. 3
0
        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;
        }
Esempio n. 4
0
 private void RightMouseUpSlot(params object[] parameters)
 {
     MouseEvent me = new MouseEvent(MouseEvent.RIGHT_MOUSE_UP)
                         {
                             CurrentEvent = (UnityEngine.Event)parameters[0],
                             GlobalPosition = (Point)parameters[1]
                         };
     DispatchEvent(me);
 }
Esempio n. 5
0
 private void MouseWheelSlot(params object[] parameters)
 {
     MouseEvent me = new MouseEvent(MouseEvent.MOUSE_WHEEL)
                         {
                             CurrentEvent = (UnityEngine.Event)parameters[0],
                             GlobalPosition = (Point)parameters[1]
                         };
     DispatchEvent(me);
 }
Esempio n. 6
0
 private void MouseUpSlot(params object[] parameters)
 {
     //Debug.Log("Mouse up! ");
     MouseEvent me = new MouseEvent(MouseEvent.MOUSE_UP)
                         {
                             CurrentEvent = (UnityEngine.Event)parameters[0],
                             GlobalPosition = (Point)parameters[1]
                         };
     DispatchEvent(me);
 }
Esempio n. 7
0
 private void MouseMoveSlot(params object[] parameters)
 {
     MouseEvent me = new MouseEvent(MouseEvent.MOUSE_MOVE)
                         {
                             //CurrentEvent = (UnityEngine.Event)parameters[0], // note: CurrentEvent is null
                             GlobalPosition = (Point)parameters[1]
                         };
     DispatchEvent(me);
 }
Esempio n. 8
0
 private void MiddleMouseDownSlot(params object[] parameters)
 {
     MouseEvent me = new MouseEvent(MouseEvent.MIDDLE_MOUSE_DOWN)
                         {
                             CurrentEvent = (UnityEngine.Event)parameters[0],
                             GlobalPosition = (Point)parameters[1]
                         };
     DispatchEvent(me);
 }
Esempio n. 9
0
        internal void MouseWheelOutsideHandler(DisplayObject popup, Point point)
        {
#if DEBUG
            if (DebugMode)
            {
                Debug.Log("MouseDownOutsideHandler: " + popup);
            }
#endif
            // dispatch from here
            MouseEvent e = new MouseEvent(MouseEvent.MOUSE_WHEEL_OUTSIDE)
                               {
                                   GlobalPosition = point, Target = popup
                               };
            DispatchEvent(e);

            if (e.Canceled)
                return;

            // dispatch from popup
            e = new MouseEvent(MouseEvent.MOUSE_WHEEL_OUTSIDE)
            {
                GlobalPosition = point
            };
            popup.DispatchEvent(e);

            if (e.Canceled)
                return;

            // check auto remove
            if (_descriptors.ContainsKey(popup) && _descriptors[popup].RemoveOnMouseWheelOutside)
            {
                RemovePopup(popup);
                return;
            }
        }
Esempio n. 10
0
        //private float _spX;
        //private float _spY;

        private void OnMouseWheel(Event e)
        {
#if DEBUG
            if (DebugMode)
                Debug.Log("MouseEventDispatcher.OnMouseWheel: " + e);
#endif
            _mouseEvent = (MouseEvent) e;

            RecalculateMouseWheelTargets();

            //UnityEngine.Event.current.delta.y

            //Debug.Log("UnityEngine.Event.current.delta: " + UnityEngine.Event.current.delta);
            //Point amount = new Point(UnityEngine.Event.current.delta.x, UnityEngine.Event.current.delta.y);

#if DEBUG
            if (DebugMode)
            {
                if (_mouseWheelTargets.Count > 0)
                {
                    Debug.Log(string.Format(@"Mouse wheel targets ({0}): 
{1}", _mouseWheelTargets.Count, ComponentUtil.DescribeComponentList(_mouseWheelTargets)));
                }
            }
#endif
            //var deltaY = UnityEngine.Event.current.delta.y;

            //foreach (Component mouseWheelTarget in _mouseWheelTargets)
            //{
            //    //if (mouseWheelTarget.StopMouseWheelPropagation)
            //    //    break;

            //    //IScrollable sc = mouseWheelTarget as IScrollable;
            //    //if (null != sc)
            //    //{
            //    //    if (sc.MouseWheelStep == 0)
            //    //        throw new Exception("MouseWheelStep of IScrollable should be greater than 0");

            //    //    //Debug.Log("!!!");
            //    //    var pixels = deltaY * sc.MouseWheelStep;
            //    //    Debug.Log("pixels: " + pixels);

            //    //    var oldVScroll = sc.VerticalScrollPosition;
            //    //    sc.VerticalScrollPosition += pixels;
            //    //    var diff = sc.VerticalScrollPosition - oldVScroll;

            //    //    var res = pixels - diff;

            //    //    //Debug.Log("diff: " + diff);
            //    //    //Debug.Log("oldVScroll: " + oldVScroll);
            //    //    //Debug.Log("sc.VerticalScrollPosition: " + sc.VerticalScrollPosition);
            //    //    //Debug.Log("res: " + res);

            //    //    //amount = amount.Divide(sc.MouseWheelStep);
            //    //    //Debug.Log("amount: " + amount);
            //    //    //if (amount.Equals(Point.Zero)) // no residuum, exit
            //    //    if (res == 0)
            //    //        break;

            //    //    deltaY = res / pixels * deltaY;
            //    //}
            //}

//            if (MouseWheelTarget == null)
//                return;
//#if DEBUG
//            if (DebugMode)
//                Debug.Log("OnMouseWheel component: " + MouseWheelTarget);
//#endif
            //IScrollable scrollable = MouseWheelTarget as IScrollable;
            //Container container = scrollable as Container;

            //Debug.Log(container);
            ////Debug.Log("    -> scrollable: " + scrollable);
            ////Debug.Log("    -> QScrollContent: " + container.QScrollContent);
            ////Debug.Log("    -> ScrollContent: " + container.ScrollContent);
            //if (null != scrollable) // ScrollContent?
            //{
            //    //bool sc = null != container ? container.QScrollContent : scrollable.ScrollContent; // commented out 20130410
            //    bool sc = scrollable.ScrollContent; // commented out 20130410
            //    Debug.Log("    -> sc: " + sc);
            //    //bool sc = scrollable.ScrollContent;
            //    if (sc)
            //    {
            //        Debug.Log(sc);
            //        var delta = UnityEngine.Event.current.delta;
            //        if (delta.x != 0 || delta.y != 0)
            //        {
            //            _spX = scrollable.ScrollPosition.X;
            //            float d = delta.y*scrollable.MouseWheelStep;
            //            Debug.Log("Delta: " + d);
            //            Debug.Log("scrollable.ScrollPosition.Y: " + scrollable.ScrollPosition.Y);
            //            _spY = scrollable.ScrollPosition.Y + d;
            //            Debug.Log("_spY 2: " + _spY);
            //            scrollable.ScrollPosition = new Point(_spX, _spY);
            //        }

            //        //scrollable.ScrollPosition = new Point(0, 100);
            //    }
            //}

            /**
             * Dispatch the mouse wheel event on the top component
             * Other component could receive the event via the event bubbling
             * */
            if (_mouseWheelTargets.Count > 0)
                MouseEventHelper.BuildAndDispatchMouseEvent(this, _mouseWheelTargets[0], MouseEvent.MOUSE_WHEEL,
                                                            _mouseEvent.GlobalPosition, _mouseEvent.CurrentEvent);

            /**
             * Stuff could have moved, so we need recalculating // 20120520
             * TODO: perhaps this needs to be defered?
             * */
            RecalculateMouseTarget();
            RecalculateMouseWheelTargets();
        }
Esempio n. 11
0
        private void OnMouseDrag(Event e)
        {
#if DEBUG
            if (DebugMode)
                Debug.Log("MouseEventDispatcher.OnMouseDrag");
#endif

            _mouseEvent = (MouseEvent) e;

            RecalculateMouseTarget();

            if (null != MouseTarget)
            {
#if DEBUG
                if (DebugMode)
                    Debug.Log("OnMouseDrag component: " + MouseTarget);
#endif
                MouseEventHelper.BuildAndDispatchMouseEvent(this, MouseTarget, MouseEvent.MOUSE_DRAG,
                                                            _mouseEvent.GlobalPosition, _mouseEvent.CurrentEvent);
            }
        }
Esempio n. 12
0
        private void OnMiddleMouseUp(Event e)
        {
#if DEBUG
            if (DebugMode)
                Debug.Log("MouseEventDispatcher.OnMiddleMouseUp");
#endif

            _mouseEvent = (MouseEvent) e;

            RecalculateMouseTarget();

            if (MouseTarget != null)
            {
#if DEBUG
                if (DebugMode)
                    Debug.Log("OnMiddleMouseUp component: " + MouseTarget);
#endif

                MouseEventHelper.BuildAndDispatchMouseEvent(this, MouseTarget, MouseEvent.MIDDLE_MOUSE_UP,
                                                            _mouseEvent.GlobalPosition, _mouseEvent.CurrentEvent);

                // click processing
                // if previously mouse-downed component is same as mouse-up component, the additional CLICK event should be fired
                // but only if no native click mode is set (button)
                //bool doProcess = true;

                //if (MouseTarget is Button)
                //{
                //    Button b = (Button) MouseTarget;
                //    /**
                //     * Check UnityClickMode
                //     * If UnityClickMode == true, do not process buttons here
                //     * but leave it to Unity
                //     * */
                //    doProcess = b.Enabled && !b.UnityClickMode;
                //}

                if (/*doProcess && */MouseTarget == _middleMouseDownComponent)
                {
#if DEBUG
                    if (DebugMode)
                        Debug.Log("MouseEventDispatcher.Click: " + MouseTarget);
#endif
                    MouseEventHelper.BuildAndDispatchMouseEvent(this, MouseTarget, MouseEvent.MIDDLE_CLICK,
                                                                _mouseEvent.GlobalPosition, _mouseEvent.CurrentEvent);

                    // middle double click?
                    if (MouseTarget == _lastClickedComponent
                        && DateTime.Now.Subtract(_lastMiddleClickedTime).TotalMilliseconds < RightDoubleClickDelay * 1000)
                        MouseEventHelper.BuildAndDispatchMouseEvent(this, MouseTarget, MouseEvent.MIDDLE_DOUBLE_CLICK,
                                                                    _mouseEvent.GlobalPosition, _mouseEvent.CurrentEvent);

                    _lastClickedComponent = MouseTarget;
                    _lastMiddleClickedTime = DateTime.Now;
                }
            }

            _mouseDownComponent = null;
            _rightMouseDownComponent = null;
            _middleMouseDownComponent = null;
        }
Esempio n. 13
0
        private void OnMiddleMouseDown(Event e)
        {

#if DEBUG
            if (DebugMode)
                Debug.Log("MouseEventDispatcher.OnMiddleMouseDown");
#endif


            _mouseEvent = (MouseEvent) e;

            RecalculateMouseTarget();

            if (MouseTarget == null)
                return;

            _middleMouseDownComponent = MouseTarget;

#if DEBUG
            if (DebugMode)
                Debug.Log("OnMiddleMouseDown component: " + MouseTarget);
#endif
            MouseEventHelper.BuildAndDispatchMouseEvent(this, MouseTarget, MouseEvent.MIDDLE_MOUSE_DOWN,
                                                        _mouseEvent.GlobalPosition, _mouseEvent.CurrentEvent);
        }
Esempio n. 14
0
        private void OnMouseDown(Event e)
        {
#if DEBUG
            if (DebugMode)
                Debug.Log("MouseEventDispatcher.OnMouseDown");
#endif
            _mouseEvent = (MouseEvent) e;

            RecalculateMouseTarget();

            if (MouseTarget == null)
                return;

            _mouseDownComponent = MouseTarget;
#if DEBUG
            if (DebugMode)
                Debug.Log("OnMouseDown component: " + MouseTarget);
#endif
            //if (null != _mouseDownComponent && null != _mouseDownComponent.Uid) // 0 != _mouseDownComponent.HotControlId && GUIUtility.keyboardControl != _mouseDownComponent.HotControlId)
            //{
            //    if (_mouseDownComponent is TextField)
            //    {
            //        //GUIUtility.keyboardControl = _mouseDownComponent.HotControlId;
            //        //Debug.Log("GUIUtility.keyboardControl: " + GUIUtility.keyboardControl);
            //        //GUI.FocusControl(_mouseDownComponent.Uid);
            //    }
            //}

            _hasBeenMouseDown = true;
            MouseEventHelper.BuildAndDispatchMouseEvent(this, MouseTarget, MouseEvent.MOUSE_DOWN,
                                                        _mouseEvent.GlobalPosition, _mouseEvent.CurrentEvent);
        }
Esempio n. 15
0
        private void OnMouseMove(Event e)
        {
#if DEBUG
            if (DebugMode)
                Debug.Log("MouseEventDispatcher.OnMouseMove");
#endif
            _mouseEvent = (MouseEvent) e;

            _pos = _mouseEvent.GlobalPosition;
            _size = SystemManager.Instance.ScreenSize;

            if (_pos.X < 0 || _pos.Y < 0 || _pos.X > _size.X || _pos.Y > _size.Y)
            {
                if (!_isMouseLeave)
                {
                    /**
                     * 1) InvalidateDrawingList the event
                     * */
                    _mouseLeaveEvent = new MouseEvent(MouseEvent.MOUSE_LEAVE)
                                           {
                                               Target = this,
                                               GlobalPosition = _pos
                                           };
                }
                _isMouseLeave = true;
            }
            else
            {
                _isMouseLeave = false;
            }

            //Debug.Log("..... will recalculate ..... ");
            /**
             * 1) Find (any) component under under mouse
             * */
            RecalculateMouseTarget();

            //RecalculateMouseWheelTargets();

            //Debug.Log("InspectMode: " + InspectMode);

            /**
             * 2) Handle inspector target under mouse
             * */
            if (PlayModeInspect || InspectMode)
            {
                RecalculateInspectorTarget();
            }

            if (null != MouseTarget)
            {
#if DEBUG
                if (DebugMode)
                    Debug.Log("OnMouseMove component: " + MouseTarget);
#endif
                MouseEventHelper.BuildAndDispatchMouseEvent(this, MouseTarget, MouseEvent.MOUSE_MOVE,
                                                            _mouseEvent.GlobalPosition, _mouseEvent.CurrentEvent);
            }

            if (MouseTarget != _previousMouseOveredComponent || _isMouseLeave)
            {
                if (null != _previousMouseOveredComponent)
                {
                    MouseEventHelper.BuildAndDispatchMouseEvent(this, _previousMouseOveredComponent,
                                                                MouseEvent.MOUSE_OUT, _mouseEvent.GlobalPosition, _mouseEvent.CurrentEvent);
                    //Debug.Log("MOUSE_OUT: " + _previousMouseOveredComponent);
                    _hasBeenMouseOut = true;

                    string cursorStyle = (string) _previousMouseOveredComponent.GetStyle("cursor");
                    if (!string.IsNullOrEmpty(cursorStyle))
                        CursorManager.Instance.RemoveCursor(_currentCursorId);
                }

                if (MouseTarget != null)
                {
                    /**
                     * MOUSE OVER
                     * */

                    if (!_hasBeenMouseDown && 0 != MouseTarget.HotControlId)
                    {
                        //GUIUtility.hotControl = MouseTarget.HotControlId;
                        //Debug.Log("GUIUtility.hotControl: " + GUIUtility.hotControl);
                    }

                    MouseEventHelper.BuildAndDispatchMouseEvent(this, MouseTarget, MouseEvent.MOUSE_OVER,
                                                                _mouseEvent.GlobalPosition, _mouseEvent.CurrentEvent);

                    string cursorStyle = (string) MouseTarget.GetStyle("cursor");
                    if (!string.IsNullOrEmpty(cursorStyle))
                        _currentCursorId = CursorManager.Instance.SetCursor(cursorStyle, CursorPriority.Low);

                    //Debug.Log("_previousMouseOveredComponent: " + _previousMouseOveredComponent);
                    //Debug.Log("_rollOveredComponents.Count: " + _rollOveredComponents.Count);

                    foreach (Component comp in _rollOveredComponents.Keys)
                    {
                        // this is the component subscribed to rollover events

                        _shouldDispatchRollOver = false;
                        _shouldDispatchRollOut = false;

                        /**
                         * 1) Both components are the child of this parent
                         * From parent's point of view, there has been no rollover nor rollout
                         * */
                        if (comp.Contains(MouseTarget, true) &&
                            null != _previousMouseOveredComponent
                            && comp.Contains(_previousMouseOveredComponent, true))
                        {
                            // do nothing
                            continue;
                        }

                        /**
                         * 2) Component child has been mouseovered.
                         * The component has not been in rollovered state.
                         * Dispatch ROLL_OVER.
                         * */
                        if (comp.Contains(MouseTarget, true) && !_rollOveredComponents[comp])
                        {
                            _shouldDispatchRollOver = true;
                            _rollOveredComponentsToChangeState.Add(comp);
                        }

                            /**
                         * 3) Component child has been mouseouted.
                         * New mouseovered component is not a child of this component, and component has been in rollovered state.
                         * Dispatch ROLL_OUT.
                         * */
                        else if (null != _previousMouseOveredComponent &&
                                 comp.Contains(_previousMouseOveredComponent, true) && _rollOveredComponents[comp])
                        {
                            _shouldDispatchRollOut = true;
                            _rollOveredComponentsToChangeState.Add(comp);
                        }

                        // rethink once again
                        // check if there has been a mouse out and no mouse in (blank Stage example)
                        //else if (_hasBeenMouseOut)// && !_shouldDispatchRollOut)
                        //{
                        //    Debug.Log("_hasBeenMouseOut");
                        //    _shouldDispatchRollOut = true;
                        //    _rollOveredComponentsToChangeState.Add(comp);
                        //}

                        if (_shouldDispatchRollOut)
                        {
#if DEBUG
                            if (DebugMode)
                            {
                                Debug.Log("Dispatching ROLL_OUT: " + comp);
                            }
#endif
                            MouseEventHelper.BuildAndDispatchMouseEvent(this, comp, MouseEvent.ROLL_OUT,
                                                                        _mouseEvent.GlobalPosition, _mouseEvent.CurrentEvent);
                        }
                        else if (_shouldDispatchRollOver)
                        {
#if DEBUG
                            if (DebugMode)
                            {
                                Debug.Log("Dispatching ROLL_OVER: " + comp);
                            }
#endif
                            MouseEventHelper.BuildAndDispatchMouseEvent(this, comp, MouseEvent.ROLL_OVER,
                                                                        _mouseEvent.GlobalPosition, _mouseEvent.CurrentEvent);
                        }
                    }
                }

                    // new mouse target is null
                else if (_hasBeenMouseOut || _isMouseLeave)
                {
                    foreach (Component comp in _rollOveredComponents.Keys)
                    {
                        /**
                         * 
                         * */
                        if (null != _previousMouseOveredComponent
                            && comp.Contains(_previousMouseOveredComponent, true)
                            && _rollOveredComponents[comp])
                        {
#if DEBUG
                            if (DebugMode)
                            {
                                Debug.Log("Dispatching ROLL_OUT (special): " + comp);
                            }
#endif
                            _rollOveredComponentsToChangeState.Add(comp);
                            MouseEventHelper.BuildAndDispatchMouseEvent(this, comp, MouseEvent.ROLL_OUT,
                                                                        _mouseEvent.GlobalPosition, _mouseEvent.CurrentEvent);
                        }
                    }
                }
            }

            _rollOveredComponentsToChangeState.ForEach(delegate(Component changing)
                                                           {
                                                               _rollOveredComponents[changing] =
                                                                   !_rollOveredComponents[changing];
                                                           });
            _rollOveredComponentsToChangeState.Clear();

            _previousMouseOveredComponent = MouseTarget;
            _hasBeenMouseOut = false;

            if (null != _mouseLeaveEvent)
            {
                /**
                 * 2) Dispatch from manager
                 * */
                DispatchEvent(_mouseLeaveEvent);
            }
        }