public bool CanDispatchEvent(EventBase evt)
 {
     return(evt is IPointerEvent);
 }
Exemple #2
0
 public EventDebuggerLogExecuteDefaultAction(EventBase evt)
 {
     m_Event = evt;
     m_Start = (long)(Time.realtimeSinceStartup * 1000.0f);
 }
        public bool UnregisterCallback <TEventType, TCallbackArgs>(EventCallback <TEventType, TCallbackArgs> callback, TrickleDown useTrickleDown = TrickleDown.NoTrickleDown) where TEventType : EventBase <TEventType>, new()
        {
            long eventTypeId = EventBase <TEventType> .TypeId();

            return(UnregisterCallback(eventTypeId, callback, useTrickleDown));
        }
Exemple #4
0
 public void LogCall(int cbHashCode, string cbName, EventBase evt, bool propagationHasStopped, bool immediatePropagationHasStopped, bool defaultHasBeenPrevented, long duration, IEventHandler mouseCapture)
 {
     AddCallObject(cbHashCode, cbName, evt, propagationHasStopped, immediatePropagationHasStopped, defaultHasBeenPrevented, duration, mouseCapture);
     UpdateModificationCount();
 }
Exemple #5
0
 public void LogExecuteDefaultAction(EventBase evt, PropagationPhase phase, long duration, IEventHandler mouseCapture)
 {
     AddExecuteDefaultAction(evt, phase, duration, mouseCapture);
     UpdateModificationCount();
 }
        protected override void ExecuteDefaultActionAtTarget(EventBase evt)
        {
            base.ExecuteDefaultActionAtTarget(evt);

            if (evt == null)
            {
                return;
            }

            if (evt.eventTypeId == KeyDownEvent.TypeId())
            {
                KeyDownEvent keyDownEvt = evt as KeyDownEvent;

                // We must handle the ETX (char 3) or the \n instead of the KeypadEnter or Return because the focus will
                //     have the drawback of having the second event to be handled by the focused field.
                if ((keyDownEvt?.character == 3) ||     // KeyCode.KeypadEnter
                    (keyDownEvt?.character == '\n'))    // KeyCode.Return
                {
                    visualInput?.Focus();
                }
            }
            // The following code is to help achieve the following behaviour:
            // On IMGUI, on any text input field in focused-non-edit-mode, doing a TAB will allow the user to get to the next control...
            // To mimic that behaviour in UIE, when in focused-non-edit-mode, we have to make sure the input is not "tabbable".
            //     So, each time, either the main TextField or the Label is receiving the focus, we remove the tabIndex on
            //     the input, and we put it back when the BlurEvent is received.
            else if (evt.eventTypeId == FocusInEvent.TypeId())
            {
                if (evt.leafTarget == this || evt.leafTarget == labelElement)
                {
                    m_VisualInputTabIndex = visualInput.tabIndex;
                    visualInput.tabIndex  = -1;
                }
            }
            // The following code was added to help achieve the following behaviour:
            // On IMGUI, doing a Return, Shift+Return or Escape will get out of the Edit mode, but stay on the control. To allow a
            //     focused-non-edit-mode, we remove the delegateFocus when we start editing to allow focusing on the parent,
            //     and we restore it when we exit the control, to prevent coming in a semi-focused state from outside the control.
            else if (evt.eventTypeId == FocusEvent.TypeId())
            {
                delegatesFocus = false;
            }
            else if (evt.eventTypeId == BlurEvent.TypeId())
            {
                delegatesFocus = true;

                if (evt.leafTarget == this || evt.leafTarget == labelElement)
                {
                    visualInput.tabIndex = m_VisualInputTabIndex;
                }
            }
            // The following code is to help achieve the following behaviour:
            // On IMGUI, on any text input field in focused-non-edit-mode, doing a TAB will allow the user to get to the next control...
            // To mimic that behaviour in UIE, when in focused-non-edit-mode, we have to make sure the input is not "tabbable".
            //     So, each time, either the main TextField or the Label is receiving the focus, we remove the tabIndex on
            //     the input, and we put it back when the BlurEvent is received.
            else if (evt.eventTypeId == FocusInEvent.TypeId())
            {
                if (showMixedValue)
                {
                    m_TextInputBase.ResetValueAndText();
                }

                if (evt.leafTarget == this || evt.leafTarget == labelElement)
                {
                    m_VisualInputTabIndex = visualInput.tabIndex;
                    visualInput.tabIndex  = -1;
                }
            }
            // The following code was added to help achieve the following behaviour:
            // On IMGUI, doing a Return, Shift+Return or Escape will get out of the Edit mode, but stay on the control. To allow a
            //     focused-non-edit-mode, we remove the delegateFocus when we start editing to allow focusing on the parent,
            //     and we restore it when we exit the control, to prevent coming in a semi-focused state from outside the control.
            else if (evt.eventTypeId == FocusEvent.TypeId())
            {
                delegatesFocus = false;
            }
            else if (evt.eventTypeId == BlurEvent.TypeId())
            {
                delegatesFocus = true;

                if (evt.leafTarget == this || evt.leafTarget == labelElement)
                {
                    visualInput.tabIndex = m_VisualInputTabIndex;
                }
            }
        }
Exemple #7
0
 public void BeginProcessEvent(EventBase evt, IEventHandler mouseCapture)
 {
     AddBeginProcessEvent(evt, mouseCapture);
     UpdateModificationCount();
 }
 protected override void ProcessDownEvent(EventBase evt, Vector2 localPosition, int pointerId)
 {
     this.startMousePosition = localPosition;
     this.dragDirection      = ClampedDragger <T> .DragDirection.None;
     base.ProcessDownEvent(evt, localPosition, pointerId);
 }
 public EventDebuggerPathTrace(IPanel panel, EventBase evt, PropagationPaths paths) : base(panel, evt, -1L, null)
 {
     this.< paths > k__BackingField = paths;
 }
Exemple #10
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;
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Get the direction of the focus change for the given event. For example, when the Tab key is pressed, focus should be given to the element to the right in the focus ring.
        /// </summary>
        public FocusChangeDirection GetFocusChangeDirection(Focusable currentFocusable, EventBase e)
        {
            if (e == null)
            {
                throw new ArgumentNullException(nameof(e));
            }

            // FUTURE:
            // We could implement an extendable adapter system to convert event to a focus change direction.
            // This would enable new event sources to change the focus.

            if (e.eventTypeId == PointerDownEvent.TypeId())
            {
                if (focusController.GetFocusableParentForPointerEvent(e.target as Focusable, out var target))
                {
                    return(VisualElementFocusChangeTarget.GetPooled(target));
                }
            }

            if (currentFocusable is IMGUIContainer && e.imguiEvent != null)
            {
                // Let IMGUIContainer manage the focus change.
                return(FocusChangeDirection.none);
            }

            return(GetKeyDownFocusChangeDirection(e));
        }
Exemple #12
0
 public bool CanDispatchEvent(EventBase evt)
 {
     return(evt is IMouseEvent || evt.imguiEvent != null);
 }
Exemple #13
0
        public FocusChangeDirection GetFocusChangeDirection(Focusable currentFocusable, EventBase e)
        {
            if (e == null)
            {
                throw new ArgumentNullException(nameof(e));
            }

            // FUTURE:
            // We could implement an extendable adapter system to convert event to a focus change direction.
            // This would enable new event sources to change the focus.

            if (currentFocusable is IMGUIContainer && e.imguiEvent != null)
            {
                // Let IMGUIContainer manage the focus change.
                return(FocusChangeDirection.none);
            }

            if (e.eventTypeId == KeyDownEvent.TypeId())
            {
                KeyDownEvent kde = e as KeyDownEvent;

                if (kde.character == (char)25 || kde.character == '\t')
                {
                    if (kde.modifiers == EventModifiers.Shift)
                    {
                        return(VisualElementFocusChangeDirection.left);
                    }
                    if (kde.modifiers == EventModifiers.None)
                    {
                        return(VisualElementFocusChangeDirection.right);
                    }
                }
            }

            return(FocusChangeDirection.none);
        }
 protected override void ExecuteDefaultAction(EventBase evt)
 {
     base.ExecuteDefaultAction(evt);
     this.editorEventHandler.ExecuteDefaultAction(evt);
 }
Exemple #15
0
 internal void SendEvent(EventBase e, DispatchMode dispatchMode = DispatchMode.Queued)
 {
     Debug.Assert(dispatcher != null);
     dispatcher?.Dispatch(e, this, dispatchMode);
 }
Exemple #16
0
 internal void ClearCachedElementUnderPointer(EventBase triggerEvent)
 {
     m_TopElementUnderPointers.SetTemporaryElementUnderPointer(null, triggerEvent);
 }
Exemple #17
0
 internal void SetElementUnderPointer(VisualElement newElementUnderPointer, EventBase triggerEvent)
 {
     m_TopElementUnderPointers.SetElementUnderPointer(newElementUnderPointer, triggerEvent);
 }
        private static void HandleEventAcrossPropagationPath(EventBase evt)
        {
            // Build and store propagation path
            var leafTarget = (VisualElement)evt.leafTarget;
            var path       = PropagationPaths.Build(leafTarget, evt);

            evt.path = path;
            EventDebugger.LogPropagationPaths(evt, path);

            var panel = leafTarget.panel;

            // Phase 1: TrickleDown phase
            // Propagate event from root to target.parent
            if (evt.tricklesDown)
            {
                evt.propagationPhase = PropagationPhase.TrickleDown;

                for (int i = path.trickleDownPath.Count - 1; i >= 0; i--)
                {
                    if (evt.isPropagationStopped)
                    {
                        break;
                    }

                    var element = path.trickleDownPath[i];
                    if (evt.Skip(element) || element.panel != panel)
                    {
                        continue;
                    }

                    evt.currentTarget = element;
                    evt.currentTarget.HandleEvent(evt);
                }
            }

            // Phase 2: Target / DefaultActionAtTarget
            // Propagate event from target parent up to root for the target phase

            // Call HandleEvent() even if propagation is stopped, for the default actions at target.
            evt.propagationPhase = PropagationPhase.AtTarget;
            foreach (var element in path.targetElements)
            {
                if (evt.Skip(element) || element.panel != panel)
                {
                    continue;
                }

                evt.target        = element;
                evt.currentTarget = evt.target;
                evt.currentTarget.HandleEvent(evt);
            }

            // Call ExecuteDefaultActionAtTarget
            evt.propagationPhase = PropagationPhase.DefaultActionAtTarget;
            foreach (var element in path.targetElements)
            {
                if (evt.Skip(element) || element.panel != panel)
                {
                    continue;
                }

                evt.target        = element;
                evt.currentTarget = evt.target;
                evt.currentTarget.HandleEvent(evt);
            }

            // Reset target to original target
            evt.target = evt.leafTarget;

            // Phase 3: bubble up phase
            // Propagate event from target parent up to root
            if (evt.bubbles)
            {
                evt.propagationPhase = PropagationPhase.BubbleUp;

                foreach (var element in path.bubbleUpPath)
                {
                    if (evt.Skip(element) || element.panel != panel)
                    {
                        continue;
                    }

                    evt.currentTarget = element;
                    evt.currentTarget.HandleEvent(evt);
                }
            }

            evt.propagationPhase = PropagationPhase.None;
            evt.currentTarget    = null;
        }
        public void ProcessEvent(EventBase evt)
        {
            IPointerEvent pointerEvent = evt as IPointerEvent;
            bool          flag         = pointerEvent == null;

            if (!flag)
            {
                bool flag2 = evt.eventTypeId == EventBase <PointerDownEvent> .TypeId() && pointerEvent.button == 0;

                if (flag2)
                {
                    this.StartClickTracking(evt);
                }
                else
                {
                    bool flag3 = evt.eventTypeId == EventBase <PointerMoveEvent> .TypeId();

                    if (flag3)
                    {
                        bool flag4 = pointerEvent.button == 0 && (pointerEvent.pressedButtons & 1) == 1;
                        if (flag4)
                        {
                            this.StartClickTracking(evt);
                        }
                        else
                        {
                            bool flag5 = pointerEvent.button == 0 && (pointerEvent.pressedButtons & 1) == 0;
                            if (flag5)
                            {
                                this.SendClickEvent(evt);
                            }
                            else
                            {
                                ClickDetector.ButtonClickStatus buttonClickStatus = this.m_ClickStatus[pointerEvent.pointerId];
                                bool flag6 = buttonClickStatus.m_Target != null;
                                if (flag6)
                                {
                                    buttonClickStatus.m_LastPointerDownTime = 0L;
                                }
                            }
                        }
                    }
                    else
                    {
                        bool flag7 = evt.eventTypeId == EventBase <PointerCancelEvent> .TypeId() || evt.eventTypeId == EventBase <PointerStationaryEvent> .TypeId() || evt.eventTypeId == EventBase <DragUpdatedEvent> .TypeId();

                        if (flag7)
                        {
                            this.CancelClickTracking(evt);
                        }
                        else
                        {
                            bool flag8 = evt.eventTypeId == EventBase <PointerUpEvent> .TypeId() && pointerEvent.button == 0;

                            if (flag8)
                            {
                                this.SendClickEvent(evt);
                            }
                        }
                    }
                }
            }
        }
Exemple #20
0
 protected override void ExecuteDefaultAction(EventBase evt)
 {
     base.ExecuteDefaultAction(evt);
     ProcessEvent(evt);
 }
Exemple #21
0
 public void EndProcessEvent(EventBase evt, long duration, IEventHandler mouseCapture)
 {
     AddEndProcessEvent(evt, duration, mouseCapture);
     UpdateModificationCount();
 }
Exemple #22
0
 internal override void ExecuteDefaultActionDisabled(EventBase evt)
 {
     base.ExecuteDefaultActionDisabled(evt);
     ProcessEvent(evt);
 }
Exemple #23
0
 public void LogIMGUICall(EventBase evt, long duration, IEventHandler mouseCapture)
 {
     AddIMGUICall(evt, duration, mouseCapture);
     UpdateModificationCount();
 }
Exemple #24
0
 public bool CanDispatchEvent(EventBase evt)
 {
     return(evt is IMouseEvent);
 }
Exemple #25
0
 public EventDebuggerLogIMGUICall(EventBase evt)
 {
     m_Event = evt;
     m_Start = (long)(Time.realtimeSinceStartup * 1000.0f);
 }
Exemple #26
0
 static bool SendEventToTarget(EventBase evt, BaseVisualElementPanel panel)
 {
     return(SendEventToRegularTarget(evt, panel) ||
            SendEventToIMGUIContainer(evt, panel));
 }
        private void OnClickEvent(EventBase evt)
        {
            bool flag = evt.eventTypeId == EventBase <MouseUpEvent> .TypeId();

            if (flag)
            {
                IMouseEvent mouseEvent = (IMouseEvent)evt;
                bool        flag2      = mouseEvent.button == 0;
                if (flag2)
                {
                    this.OnClick();
                }
            }
            else
            {
                bool flag3 = evt.eventTypeId == EventBase <PointerUpEvent> .TypeId() || evt.eventTypeId == EventBase <ClickEvent> .TypeId();

                if (flag3)
                {
                    IPointerEvent pointerEvent = (IPointerEvent)evt;
                    bool          flag4        = pointerEvent.button == 0;
                    if (flag4)
                    {
                        this.OnClick();
                    }
                }
            }
        }
Exemple #28
0
 private bool IsRelevantEvent(EventBase evt)
 {
     return(IsContainerCapturingTheMouse() || !IsLocalEvent(evt) || IsEventInsideLocalWindow(evt));
 }
Exemple #29
0
            protected internal override void ExecuteDefaultAction(EventBase evt)
            {
                base.ExecuteDefaultAction(evt);

                editorEventHandler.ExecuteDefaultAction(evt);
            }
Exemple #30
0
 public abstract void DisplayMenuIfEventMatches(EventBase evt, IEventHandler eventHandler);