static void UpdateElementUnderMouse(EventBase evt, BaseVisualElementPanel panel, out VisualElement elementUnderMouse)
        {
            bool shouldRecomputeTopElementUnderMouse = (evt as IMouseEventInternal)?.recomputeTopElementUnderMouse ?? true;

            elementUnderMouse = shouldRecomputeTopElementUnderMouse
                ? panel.RecomputeTopElementUnderPointer(PointerId.mousePointerId, ((IMouseEvent)evt).mousePosition, evt)
                : panel.GetTopElementUnderPointer(PointerId.mousePointerId);

            // If mouse leaves the window, make sure element under mouse is null.
            // However, if pressed button != 0, we are getting a MouseLeaveWindowEvent as part of
            // of a drag and drop operation, at the very beginning of the drag. Since
            // we are not really exiting the window, we do not want to set the element
            // under mouse to null in this case.
            if (evt.eventTypeId == MouseLeaveWindowEvent.TypeId() &&
                (evt as MouseLeaveWindowEvent).pressedButtons == 0)
            {
                panel.ClearCachedElementUnderPointer(PointerId.mousePointerId, evt);
            }
        }
示例#2
0
        public void DispatchEvent(EventBase evt, IPanel panel)
        {
            EventBehavior captureBehavior = EventBehavior.None;

            IEventHandler capturingElement = panel?.GetCapturingElement(PointerId.mousePointerId);

            if (capturingElement == null)
            {
                return;
            }

            // Release mouse capture if capture element is not in a panel.
            VisualElement captureVE = capturingElement as VisualElement;

            if (evt.eventTypeId != MouseCaptureOutEvent.TypeId() && captureVE != null && captureVE.panel == null)
            {
                captureVE.ReleaseMouse();
                return;
            }

            if (panel != null && captureVE != null && captureVE.panel.contextType != panel.contextType)
            {
                return;
            }

            IMouseEvent mouseEvent = evt as IMouseEvent;

            if (mouseEvent != null && (evt.target == null || evt.target == capturingElement))
            {
                // Exclusive processing by capturing element.
                captureBehavior  = EventBehavior.IsCapturable;
                captureBehavior |= EventBehavior.IsSentExclusivelyToCapturingElement;
            }
            else if (evt.imguiEvent != null && evt.target == null)
            {
                // Non exclusive processing by capturing element.
                captureBehavior = EventBehavior.IsCapturable;
            }

            if (evt.eventTypeId == MouseEnterWindowEvent.TypeId() ||
                evt.eventTypeId == MouseLeaveWindowEvent.TypeId() ||
                evt.eventTypeId == WheelEvent.TypeId())
            {
                captureBehavior = EventBehavior.None;
            }

            if ((captureBehavior & EventBehavior.IsCapturable) == EventBehavior.IsCapturable)
            {
                BaseVisualElementPanel basePanel = panel as BaseVisualElementPanel;

                if (mouseEvent != null && basePanel != null)
                {
                    bool shouldRecomputeTopElementUnderMouse = (mouseEvent as IMouseEventInternal)?.recomputeTopElementUnderMouse ?? true;

                    if (shouldRecomputeTopElementUnderMouse)
                    {
                        basePanel.RecomputeTopElementUnderPointer(mouseEvent.mousePosition, evt);
                    }
                }

                evt.dispatch      = true;
                evt.target        = capturingElement;
                evt.currentTarget = capturingElement;
                (capturingElement as CallbackEventHandler)?.HandleEventAtTargetPhase(evt);
                // Do further processing with a target computed the usual way.
                // However, if IsSentExclusivelyToCapturingElement, the only thing remaining to do is ExecuteDefaultAction,
                // which should be done with mouseCapture as the target.
                if ((captureBehavior & EventBehavior.IsSentExclusivelyToCapturingElement) != EventBehavior.IsSentExclusivelyToCapturingElement)
                {
                    evt.target = null;
                }

                evt.currentTarget    = null;
                evt.propagationPhase = PropagationPhase.None;
                evt.dispatch         = false;

                // Do not call HandleEvent again for this element.
                evt.skipElements.Add(capturingElement);

                evt.stopDispatch = (captureBehavior & EventBehavior.IsSentExclusivelyToCapturingElement) == EventBehavior.IsSentExclusivelyToCapturingElement;

                if (evt.target is IMGUIContainer)
                {
                    evt.propagateToIMGUI = true;
                    evt.skipElements.Add(evt.target);
                }
                else
                {
                    evt.propagateToIMGUI = false;
                }
            }
        }
示例#3
0
        private static void UpdateElementUnderPointer(EventBase evt, IPanel panel, out VisualElement elementUnderPointer)
        {
            IPointerEvent          pointerEvent           = evt as IPointerEvent;
            BaseVisualElementPanel baseVisualElementPanel = panel as BaseVisualElementPanel;
            IPointerEventInternal  expr_15 = evt as IPointerEventInternal;

            elementUnderPointer = ((expr_15 == null || expr_15.recomputeTopElementUnderPointer) ? ((baseVisualElementPanel != null) ? baseVisualElementPanel.RecomputeTopElementUnderPointer(pointerEvent.position, evt) : null) : ((baseVisualElementPanel != null) ? baseVisualElementPanel.GetTopElementUnderPointer(pointerEvent.pointerId) : null));
        }
        private static void UpdateElementUnderMouse(EventBase evt, BaseVisualElementPanel panel, out VisualElement elementUnderMouse)
        {
            IMouseEventInternal expr_07 = evt as IMouseEventInternal;

            elementUnderMouse = ((expr_07 == null || expr_07.recomputeTopElementUnderMouse) ? panel.RecomputeTopElementUnderPointer(((IMouseEvent)evt).mousePosition, evt) : panel.GetTopElementUnderPointer(PointerId.mousePointerId));
            bool flag = evt.eventTypeId == EventBase <MouseLeaveWindowEvent> .TypeId() && (evt as MouseLeaveWindowEvent).pressedButtons == 0;

            if (flag)
            {
                panel.ClearCachedElementUnderPointer(evt);
            }
        }
        public void DispatchEvent(EventBase evt, IPanel panel)
        {
            EventBehavior captureBehavior = EventBehavior.None;

            IEventHandler capturingElement = panel?.GetCapturingElement(PointerId.mousePointerId);

            if (capturingElement == null)
            {
                return;
            }

            // Release mouse capture if capture element is not in a panel.
            VisualElement captureVE = capturingElement as VisualElement;

            if (evt.eventTypeId != MouseCaptureOutEvent.TypeId() && captureVE != null && captureVE.panel == null)
            {
                captureVE.ReleaseMouse();
                return;
            }

            // Case 1342115: mouse position is in local panel coordinates; sending event to a target from a different
            // panel will lead to a wrong position, so we don't allow it. Note that in general the mouse-down-move-up
            // sequence still works properly because the OS captures the mouse on the starting EditorWindow.
            if (panel != null && captureVE != null && captureVE.panel != panel)
            {
                return;
            }

            IMouseEvent mouseEvent = evt as IMouseEvent;

            if (mouseEvent != null && (evt.target == null || evt.target == capturingElement))
            {
                // Exclusive processing by capturing element.
                captureBehavior  = EventBehavior.IsCapturable;
                captureBehavior |= EventBehavior.IsSentExclusivelyToCapturingElement;
            }
            else if (evt.imguiEvent != null && evt.target == null)
            {
                // Non exclusive processing by capturing element.
                captureBehavior = EventBehavior.IsCapturable;
            }

            if (evt.eventTypeId == MouseEnterWindowEvent.TypeId() ||
                evt.eventTypeId == MouseLeaveWindowEvent.TypeId() ||
                evt.eventTypeId == WheelEvent.TypeId())
            {
                captureBehavior = EventBehavior.None;
            }

            if ((captureBehavior & EventBehavior.IsCapturable) == EventBehavior.IsCapturable)
            {
                BaseVisualElementPanel basePanel = panel as BaseVisualElementPanel;

                if (mouseEvent != null && basePanel != null)
                {
                    bool shouldRecomputeTopElementUnderMouse = (mouseEvent as IMouseEventInternal)?.recomputeTopElementUnderMouse ?? true;

                    if (shouldRecomputeTopElementUnderMouse)
                    {
                        basePanel.RecomputeTopElementUnderPointer(PointerId.mousePointerId, mouseEvent.mousePosition, evt);
                    }
                }

                evt.dispatch = true;
                evt.target   = capturingElement;
                var skipDisabledElements = evt.skipDisabledElements;
                evt.skipDisabledElements = false;
                (capturingElement as CallbackEventHandler)?.HandleEventAtTargetPhase(evt);
                // Do further processing with a target computed the usual way.
                // However, if IsSentExclusivelyToCapturingElement, the only thing remaining to do is ExecuteDefaultAction,
                // which should be done with mouseCapture as the target.
                if ((captureBehavior & EventBehavior.IsSentExclusivelyToCapturingElement) != EventBehavior.IsSentExclusivelyToCapturingElement)
                {
                    evt.target = null;
                    evt.skipDisabledElements = skipDisabledElements;
                }

                evt.currentTarget    = null;
                evt.propagationPhase = PropagationPhase.None;
                evt.dispatch         = false;

                // Do not call HandleEvent again for this element.
                evt.skipElements.Add(capturingElement);

                evt.stopDispatch = (captureBehavior & EventBehavior.IsSentExclusivelyToCapturingElement) == EventBehavior.IsSentExclusivelyToCapturingElement;

                if (evt.target is IMGUIContainer)
                {
                    evt.propagateToIMGUI = true;
                    evt.skipElements.Add(evt.target);
                }
                else
                {
                    evt.propagateToIMGUI = false;
                }
            }
        }
示例#6
0
        public void DispatchEvent(EventBase evt, IPanel panel)
        {
            MouseCaptureDispatchingStrategy.EventBehavior eventBehavior = MouseCaptureDispatchingStrategy.EventBehavior.None;
            IEventHandler eventHandler = (panel != null) ? panel.GetCapturingElement(PointerId.mousePointerId) : null;
            bool          flag         = eventHandler == null;

            if (!flag)
            {
                VisualElement visualElement = eventHandler as VisualElement;
                bool          flag2         = evt.eventTypeId != EventBase <MouseCaptureOutEvent> .TypeId() && visualElement != null && visualElement.panel == null;

                if (flag2)
                {
                    visualElement.ReleaseMouse();
                }
                else
                {
                    bool flag3 = panel != null && visualElement != null && visualElement.panel.contextType != panel.contextType;
                    if (!flag3)
                    {
                        IMouseEvent mouseEvent = evt as IMouseEvent;
                        bool        flag4      = mouseEvent != null && (evt.target == null || evt.target == eventHandler);
                        if (flag4)
                        {
                            eventBehavior  = MouseCaptureDispatchingStrategy.EventBehavior.IsCapturable;
                            eventBehavior |= MouseCaptureDispatchingStrategy.EventBehavior.IsSentExclusivelyToCapturingElement;
                        }
                        else
                        {
                            bool flag5 = evt.imguiEvent != null && evt.target == null;
                            if (flag5)
                            {
                                eventBehavior = MouseCaptureDispatchingStrategy.EventBehavior.IsCapturable;
                            }
                        }
                        bool flag6 = evt.eventTypeId == EventBase <MouseEnterWindowEvent> .TypeId() || evt.eventTypeId == EventBase <MouseLeaveWindowEvent> .TypeId() || evt.eventTypeId == EventBase <WheelEvent> .TypeId();

                        if (flag6)
                        {
                            eventBehavior = MouseCaptureDispatchingStrategy.EventBehavior.None;
                        }
                        bool flag7 = (eventBehavior & MouseCaptureDispatchingStrategy.EventBehavior.IsCapturable) == MouseCaptureDispatchingStrategy.EventBehavior.IsCapturable;
                        if (flag7)
                        {
                            BaseVisualElementPanel baseVisualElementPanel = panel as BaseVisualElementPanel;
                            bool flag8 = mouseEvent != null && baseVisualElementPanel != null;
                            if (flag8)
                            {
                                IMouseEventInternal expr_139 = mouseEvent as IMouseEventInternal;
                                bool flag9  = expr_139 == null || expr_139.recomputeTopElementUnderMouse;
                                bool flag10 = flag9;
                                if (flag10)
                                {
                                    baseVisualElementPanel.RecomputeTopElementUnderPointer(mouseEvent.mousePosition, evt);
                                }
                            }
                            evt.dispatch = true;
                            evt.target   = eventHandler;
                            CallbackEventHandler expr_175 = eventHandler as CallbackEventHandler;
                            if (expr_175 != null)
                            {
                                expr_175.HandleEventAtTargetPhase(evt);
                            }
                            bool flag11 = (eventBehavior & MouseCaptureDispatchingStrategy.EventBehavior.IsSentExclusivelyToCapturingElement) != MouseCaptureDispatchingStrategy.EventBehavior.IsSentExclusivelyToCapturingElement;
                            if (flag11)
                            {
                                evt.target = null;
                            }
                            evt.currentTarget    = null;
                            evt.propagationPhase = PropagationPhase.None;
                            evt.dispatch         = false;
                            evt.skipElements.Add(eventHandler);
                            evt.stopDispatch = ((eventBehavior & MouseCaptureDispatchingStrategy.EventBehavior.IsSentExclusivelyToCapturingElement) == MouseCaptureDispatchingStrategy.EventBehavior.IsSentExclusivelyToCapturingElement);
                            bool flag12 = evt.target is IMGUIContainer;
                            if (flag12)
                            {
                                evt.propagateToIMGUI = true;
                                evt.skipElements.Add(evt.target);
                            }
                            else
                            {
                                evt.propagateToIMGUI = false;
                            }
                        }
                    }
                }
            }
        }