// In order for tests to run without an EditorWindow but still be able to send
 // events, we sometimes need to force the event type. IMGUI::GetEventType() (native) will
 // return the event type as Ignore if the proper views haven't yet been
 // initialized. This (falsely) breaks tests that rely on the event type. So for tests, we
 // just ensure the event type is what we originally set it to when we sent it.
 internal static EventBase CreateEvent(Event systemEvent, EventType eventType)
 {
     switch (eventType)
     {
         case EventType.MouseMove:
             return PointerMoveEvent.GetPooled(systemEvent);
         case EventType.MouseDrag:
             return PointerMoveEvent.GetPooled(systemEvent);
         case EventType.MouseDown:
             // If some buttons are already down, we generate PointerMove/MouseDown events.
             // Otherwise we generate PointerDown/MouseDown events.
             // See W3C pointer events recommendation: https://www.w3.org/TR/pointerevents2
             if (PointerDeviceState.GetPressedButtons(PointerId.mousePointerId) != 0)
             {
                 return PointerMoveEvent.GetPooled(systemEvent);
             }
             else
             {
                 return PointerDownEvent.GetPooled(systemEvent);
             }
         case EventType.MouseUp:
             // If more buttons are still down, we generate PointerMove/MouseUp events.
             // Otherwise we generate PointerUp/MouseUp events.
             // See W3C pointer events recommendation: https://www.w3.org/TR/pointerevents2
             if (PointerDeviceState.HasAdditionalPressedButtons(PointerId.mousePointerId, systemEvent.button))
             {
                 return PointerMoveEvent.GetPooled(systemEvent);
             }
             else
             {
                 return PointerUpEvent.GetPooled(systemEvent);
             }
         case EventType.ContextClick:
             return ContextClickEvent.GetPooled(systemEvent);
         case EventType.MouseEnterWindow:
             return MouseEnterWindowEvent.GetPooled(systemEvent);
         case EventType.MouseLeaveWindow:
             return MouseLeaveWindowEvent.GetPooled(systemEvent);
         case EventType.ScrollWheel:
             return WheelEvent.GetPooled(systemEvent);
         case EventType.KeyDown:
             return KeyDownEvent.GetPooled(systemEvent);
         case EventType.KeyUp:
             return KeyUpEvent.GetPooled(systemEvent);
         case EventType.DragUpdated:
             return DragUpdatedEvent.GetPooled(systemEvent);
         case EventType.DragPerform:
             return DragPerformEvent.GetPooled(systemEvent);
         case EventType.DragExited:
             return DragExitedEvent.GetPooled(systemEvent);
         case EventType.ValidateCommand:
             return ValidateCommandEvent.GetPooled(systemEvent);
         case EventType.ExecuteCommand:
             return ExecuteCommandEvent.GetPooled(systemEvent);
         default:// Layout, Ignore, Used
             return IMGUIEvent.GetPooled(systemEvent);
     }
 }
Пример #2
0
        // In order for tests to run without an EditorWindow but still be able to send
        // events, we sometimes need to force the event type. IMGUI::GetEventType() (native) will
        // return the event type as Ignore if the proper views haven't yet been
        // initialized. This (falsely) breaks tests that rely on the event type. So for tests, we
        // just ensure the event type is what we originally set it to when we sent it.
        internal static EventBase CreateEvent(Event systemEvent, EventType eventType)
        {
            switch (eventType)
            {
            case EventType.MouseMove:
                return(MouseMoveEvent.GetPooled(systemEvent));

            case EventType.MouseDrag:
                return(MouseMoveEvent.GetPooled(systemEvent));

            case EventType.MouseDown:
                return(MouseDownEvent.GetPooled(systemEvent));

            case EventType.MouseUp:
                return(MouseUpEvent.GetPooled(systemEvent));

            case EventType.ContextClick:
                return(ContextClickEvent.GetPooled(systemEvent));

            case EventType.MouseEnterWindow:
                return(MouseEnterWindowEvent.GetPooled(systemEvent));

            case EventType.MouseLeaveWindow:
                return(MouseLeaveWindowEvent.GetPooled(systemEvent));

            case EventType.ScrollWheel:
                return(WheelEvent.GetPooled(systemEvent));

            case EventType.KeyDown:
                return(KeyDownEvent.GetPooled(systemEvent));

            case EventType.KeyUp:
                return(KeyUpEvent.GetPooled(systemEvent));

            case EventType.DragUpdated:
                return(DragUpdatedEvent.GetPooled(systemEvent));

            case EventType.DragPerform:
                return(DragPerformEvent.GetPooled(systemEvent));

            case EventType.DragExited:
                return(DragExitedEvent.GetPooled(systemEvent));

            case EventType.ValidateCommand:
                return(ValidateCommandEvent.GetPooled(systemEvent));

            case EventType.ExecuteCommand:
                return(ExecuteCommandEvent.GetPooled(systemEvent));

            default:    // Layout, Ignore, Used
                return(IMGUIEvent.GetPooled(systemEvent));
            }
        }
Пример #3
0
        internal static EventBase CreateEvent(Event systemEvent, EventType eventType)
        {
            EventBase pooled;

            switch (eventType)
            {
            case EventType.MouseDown:
            {
                bool flag = PointerDeviceState.HasAdditionalPressedButtons(PointerId.mousePointerId, systemEvent.button);
                if (flag)
                {
                    pooled = PointerEventBase <PointerMoveEvent> .GetPooled(systemEvent);

                    return(pooled);
                }
                pooled = PointerEventBase <PointerDownEvent> .GetPooled(systemEvent);

                return(pooled);
            }

            case EventType.MouseUp:
            {
                bool flag2 = PointerDeviceState.HasAdditionalPressedButtons(PointerId.mousePointerId, systemEvent.button);
                if (flag2)
                {
                    pooled = PointerEventBase <PointerMoveEvent> .GetPooled(systemEvent);

                    return(pooled);
                }
                pooled = PointerEventBase <PointerUpEvent> .GetPooled(systemEvent);

                return(pooled);
            }

            case EventType.MouseMove:
                pooled = PointerEventBase <PointerMoveEvent> .GetPooled(systemEvent);

                return(pooled);

            case EventType.MouseDrag:
                pooled = PointerEventBase <PointerMoveEvent> .GetPooled(systemEvent);

                return(pooled);

            case EventType.KeyDown:
                pooled = KeyboardEventBase <KeyDownEvent> .GetPooled(systemEvent);

                return(pooled);

            case EventType.KeyUp:
                pooled = KeyboardEventBase <KeyUpEvent> .GetPooled(systemEvent);

                return(pooled);

            case EventType.ScrollWheel:
                pooled = WheelEvent.GetPooled(systemEvent);
                return(pooled);

            case EventType.DragUpdated:
                pooled = DragUpdatedEvent.GetPooled(systemEvent);
                return(pooled);

            case EventType.DragPerform:
                pooled = MouseEventBase <DragPerformEvent> .GetPooled(systemEvent);

                return(pooled);

            case EventType.ValidateCommand:
                pooled = CommandEventBase <ValidateCommandEvent> .GetPooled(systemEvent);

                return(pooled);

            case EventType.ExecuteCommand:
                pooled = CommandEventBase <ExecuteCommandEvent> .GetPooled(systemEvent);

                return(pooled);

            case EventType.DragExited:
                pooled = DragExitedEvent.GetPooled(systemEvent);
                return(pooled);

            case EventType.ContextClick:
                pooled = MouseEventBase <ContextClickEvent> .GetPooled(systemEvent);

                return(pooled);

            case EventType.MouseEnterWindow:
                pooled = MouseEventBase <MouseEnterWindowEvent> .GetPooled(systemEvent);

                return(pooled);

            case EventType.MouseLeaveWindow:
                pooled = MouseLeaveWindowEvent.GetPooled(systemEvent);
                return(pooled);
            }
            pooled = IMGUIEvent.GetPooled(systemEvent);
            return(pooled);
        }
Пример #4
0
        // In order for tests to run without an EditorWindow but still be able to send
        // events, we sometimes need to force the event type. IMGUI::GetEventType() (native) will
        // return the event type as Ignore if the proper views haven't yet been
        // initialized. This (falsely) breaks tests that rely on the event type. So for tests, we
        // just ensure the event type is what we originally set it to when we sent it.
        internal static EventBase CreateEvent(Event systemEvent, EventType eventType)
        {
            switch (eventType)
            {
            case EventType.MouseMove:
                return(PointerMoveEvent.GetPooled(systemEvent));

            case EventType.MouseDrag:
                return(PointerMoveEvent.GetPooled(systemEvent));

            case EventType.MouseDown:
                // If some buttons are already down, we generate PointerMove/MouseDown events.
                // Otherwise we generate PointerDown/MouseDown events.
                // See W3C pointer events recommendation: https://www.w3.org/TR/pointerevents2
                // Note: sometimes systemEvent.button is already pressed (systemEvent is processed multiple times).
                if (PointerDeviceState.HasAdditionalPressedButtons(PointerId.mousePointerId, systemEvent.button))
                {
                    return(PointerMoveEvent.GetPooled(systemEvent));
                }
                else
                {
                    return(PointerDownEvent.GetPooled(systemEvent));
                }

            case EventType.MouseUp:
                // If more buttons are still down, we generate PointerMove/MouseUp events.
                // Otherwise we generate PointerUp/MouseUp events.
                // See W3C pointer events recommendation: https://www.w3.org/TR/pointerevents2
                if (PointerDeviceState.HasAdditionalPressedButtons(PointerId.mousePointerId, systemEvent.button))
                {
                    return(PointerMoveEvent.GetPooled(systemEvent));
                }
                else
                {
                    return(PointerUpEvent.GetPooled(systemEvent));
                }

            case EventType.ContextClick:
                return(ContextClickEvent.GetPooled(systemEvent));

            case EventType.MouseEnterWindow:
                return(MouseEnterWindowEvent.GetPooled(systemEvent));

            case EventType.MouseLeaveWindow:
                return(MouseLeaveWindowEvent.GetPooled(systemEvent));

            case EventType.ScrollWheel:
                return(WheelEvent.GetPooled(systemEvent));

            case EventType.KeyDown:
                return(KeyDownEvent.GetPooled(systemEvent));

            case EventType.KeyUp:
                return(KeyUpEvent.GetPooled(systemEvent));

#if UNITY_EDITOR
            case EventType.DragUpdated:
                return(DragUpdatedEvent.GetPooled(systemEvent));

            case EventType.DragPerform:
                return(DragPerformEvent.GetPooled(systemEvent));

            case EventType.DragExited:
                return(DragExitedEvent.GetPooled(systemEvent));
#endif
            case EventType.ValidateCommand:
                return(ValidateCommandEvent.GetPooled(systemEvent));

            case EventType.ExecuteCommand:
                return(ExecuteCommandEvent.GetPooled(systemEvent));

            default:    // Layout, Ignore, Used
                return(IMGUIEvent.GetPooled(systemEvent));
            }
        }