private void ProcessEvent(EventBase evt, IPanel panel)
        {
            Event imguiEvent = evt.imguiEvent;
            bool  flag       = imguiEvent != null && imguiEvent.rawType == EventType.Used;

            using (new EventDispatcherGate(this))
            {
                evt.PreDispatch(panel);
                bool flag2 = !evt.stopDispatch && !evt.isPropagationStopped;
                if (flag2)
                {
                    this.ApplyDispatchingStrategies(evt, panel, flag);
                }
                bool flag3 = evt.path != null;
                if (flag3)
                {
                    foreach (VisualElement current in evt.path.targetElements)
                    {
                        evt.target = current;
                        EventDispatchUtilities.ExecuteDefaultAction(evt, panel);
                    }
                    evt.target = evt.leafTarget;
                }
                else
                {
                    EventDispatchUtilities.ExecuteDefaultAction(evt, panel);
                }
                this.m_DebuggerEventDispatchingStrategy.PostDispatch(evt, panel);
                evt.PostDispatch(panel);
                this.m_ClickDetector.ProcessEvent(evt);
                Debug.Assert(flag || evt.isPropagationStopped || imguiEvent == null || imguiEvent.rawType != EventType.Used, "Event is used but not stopped.");
            }
        }
Exemplo n.º 2
0
        void ProcessEvent(EventBase evt, IPanel panel)
        {
            Event e = evt.imguiEvent;
            // Sometimes (in tests only?) we receive Used events. Protect our verification from this case.
            bool imguiEventIsInitiallyUsed = e != null && e.type == EventType.Used;

            using (new EventDispatcherGate(this))
            {
                evt.PreDispatch(panel);

                IMouseEvent         mouseEvent         = evt as IMouseEvent;
                IMouseEventInternal mouseEventInternal = evt as IMouseEventInternal;
                if (mouseEvent != null && mouseEventInternal != null && mouseEventInternal.triggeredByOS)
                {
                    MousePositionTracker.SaveMousePosition(mouseEvent.mousePosition, panel);
                }

                foreach (var strategy in m_DispatchingStrategies)
                {
                    if (strategy.CanDispatchEvent(evt))
                    {
                        strategy.DispatchEvent(evt, panel);

                        Debug.Assert(imguiEventIsInitiallyUsed || evt.isPropagationStopped || e == null || e.type != EventType.Used,
                                     "Unexpected condition: !evt.isPropagationStopped && evt.imguiEvent.type == EventType.Used.");

                        if (evt.stopDispatch || evt.isPropagationStopped)
                        {
                            break;
                        }
                    }
                }

                if (evt.path != null)
                {
                    foreach (var element in evt.path.targetElements)
                    {
                        evt.target = element;
                        EventDispatchUtilities.ExecuteDefaultAction(evt, panel);
                    }

                    evt.target = evt.leafTarget;
                }
                else
                {
                    EventDispatchUtilities.ExecuteDefaultAction(evt, panel);
                }

                evt.PostDispatch(panel);

                m_DebuggerEventDispatchingStrategy.PostDispatch(evt, panel);

                Debug.Assert(imguiEventIsInitiallyUsed || evt.isPropagationStopped || e == null || e.type != EventType.Used, "Event is used but not stopped.");
            }
        }
Exemplo n.º 3
0
        void ProcessEvent(EventBase evt, IPanel panel)
        {
            Event e = evt.imguiEvent;
            // Sometimes (in tests only?) we receive Used events. Protect our verification from this case.
            bool imguiEventIsInitiallyUsed = e != null && e.rawType == EventType.Used;

            using (new EventDispatcherGate(this))
            {
                evt.PreDispatch(panel);

                foreach (var strategy in m_DispatchingStrategies)
                {
                    if (strategy.CanDispatchEvent(evt))
                    {
                        strategy.DispatchEvent(evt, panel);

                        Debug.Assert(imguiEventIsInitiallyUsed || evt.isPropagationStopped || e == null || e.rawType != EventType.Used,
                                     "Unexpected condition: !evt.isPropagationStopped && evt.imguiEvent.rawType == EventType.Used.");

                        if (evt.stopDispatch || evt.isPropagationStopped)
                        {
                            break;
                        }
                    }
                }

                if (evt.path != null)
                {
                    foreach (var element in evt.path.targetElements)
                    {
                        evt.target = element;
                        EventDispatchUtilities.ExecuteDefaultAction(evt, panel);
                    }

                    // Reset target to leaf target
                    evt.target = evt.leafTarget;
                }
                else
                {
                    EventDispatchUtilities.ExecuteDefaultAction(evt, panel);
                }

                m_DebuggerEventDispatchingStrategy.PostDispatch(evt, panel);

                evt.PostDispatch(panel);

                m_ClickDetector.ProcessEvent(evt);

                Debug.Assert(imguiEventIsInitiallyUsed || evt.isPropagationStopped || e == null || e.rawType != EventType.Used, "Event is used but not stopped.");
            }
        }
Exemplo n.º 4
0
        void ProcessEvent(EventBase evt, IPanel panel)
        {
            Event e = evt.imguiEvent;
            // Sometimes (in tests only?) we receive Used events. Protect our verification from this case.
            bool imguiEventIsInitiallyUsed = e != null && e.rawType == EventType.Used;

            using (new EventDispatcherGate(this))
            {
                evt.PreDispatch(panel);

                if (!evt.stopDispatch && !evt.isPropagationStopped)
                {
                    ApplyDispatchingStrategies(evt, panel, imguiEventIsInitiallyUsed);
                }

                if (evt.path != null)
                {
                    foreach (var element in evt.path.targetElements)
                    {
                        if (element.panel == panel)
                        {
                            evt.target = element;
                            EventDispatchUtilities.ExecuteDefaultAction(evt);
                        }
                    }

                    // Reset target to leaf target
                    evt.target = evt.leafTarget;
                }
                else
                {
                    // If no propagation path, make sure EventDispatchUtilities.ExecuteDefaultAction has a target
                    if (evt.target == null && panel != null)
                    {
                        evt.target = panel.visualTree;
                    }
                    EventDispatchUtilities.ExecuteDefaultAction(evt);
                }

                m_DebuggerEventDispatchingStrategy.PostDispatch(evt, panel);

                evt.PostDispatch(panel);

                m_ClickDetector.ProcessEvent(evt);

                Debug.Assert(imguiEventIsInitiallyUsed || evt.isPropagationStopped || e == null || e.rawType != EventType.Used, "Event is used but not stopped.");
            }
        }
Exemplo n.º 5
0
        void ProcessEvent(EventBase evt, [NotNull] IPanel panel)
        {
            Event e = evt.imguiEvent;
            // Sometimes (in tests only?) we receive Used events. Protect our verification from this case.
            bool imguiEventIsInitiallyUsed = e != null && e.rawType == EventType.Used;

            using (new EventDispatcherGate(this))
            {
                evt.PreDispatch(panel);

                if (!evt.stopDispatch && !evt.isPropagationStopped)
                {
                    ApplyDispatchingStrategies(evt, panel, imguiEventIsInitiallyUsed);
                }

                // Last chance to build a path. Some dispatching strategies (e.g. PointerCaptureDispatchingStrategy)
                // don't call PropagateEvents but still need to call ExecuteDefaultActions on composite roots.
                var path = evt.path;
                if (path == null && evt.bubblesOrTricklesDown && evt.leafTarget is VisualElement leafTarget)
                {
                    path     = PropagationPaths.Build(leafTarget, evt);
                    evt.path = path;
                    EventDebugger.LogPropagationPaths(evt, path);
                }

                if (path != null)
                {
                    foreach (var element in path.targetElements)
                    {
                        if (element.panel == panel)
                        {
                            evt.target = element;
                            EventDispatchUtilities.ExecuteDefaultAction(evt);
                        }
                    }

                    // Reset target to leaf target
                    evt.target = evt.leafTarget;
                }
                else
                {
                    // If no propagation path, make sure EventDispatchUtilities.ExecuteDefaultAction has a target
                    if (!(evt.target is VisualElement target))
                    {
                        evt.target = target = panel.visualTree;
                    }

                    if (target.panel == panel)
                    {
                        EventDispatchUtilities.ExecuteDefaultAction(evt);
                    }
                }

                m_DebuggerEventDispatchingStrategy.PostDispatch(evt, panel);

                evt.PostDispatch(panel);

                m_ClickDetector.ProcessEvent(evt);

                Debug.Assert(imguiEventIsInitiallyUsed || evt.isPropagationStopped || e == null || e.rawType != EventType.Used, "Event is used but not stopped.");
            }
        }