internal static EventBase CreateEvent(Event systemEvent)
        {
            EventBase pooled;

            switch (systemEvent.type)
            {
            case EventType.MouseDown:
                pooled = MouseEventBase <MouseDownEvent> .GetPooled(systemEvent);

                break;

            case EventType.MouseUp:
                pooled = MouseEventBase <MouseUpEvent> .GetPooled(systemEvent);

                break;

            case EventType.MouseMove:
                pooled = MouseEventBase <MouseMoveEvent> .GetPooled(systemEvent);

                break;

            case EventType.MouseDrag:
                pooled = MouseEventBase <MouseMoveEvent> .GetPooled(systemEvent);

                break;

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

                break;

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

                break;

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

            default:
                pooled = IMGUIEvent.GetPooled(systemEvent);
                break;
            }
            return(pooled);
        }
Exemple #2
0
 private void DoOnGUI(Event evt)
 {
     if (this.m_OnGUIHandler != null && base.panel != null)
     {
         int num = GUIClip.Internal_GetCount();
         this.SaveGlobals();
         UIElementsUtility.BeginContainerGUI(this.cache, evt, this);
         if (evt.type != EventType.Layout)
         {
             if (this.lostFocus)
             {
                 if (this.focusController != null)
                 {
                     if (this.focusController.focusedElement == null || this.focusController.focusedElement == this || !(this.focusController.focusedElement is IMGUIContainer))
                     {
                         GUIUtility.keyboardControl = 0;
                         this.focusController.imguiKeyboardControl = 0;
                     }
                 }
                 this.lostFocus = false;
             }
             if (this.receivedFocus)
             {
                 if (this.focusChangeDirection != FocusChangeDirection.unspecified && this.focusChangeDirection != FocusChangeDirection.none)
                 {
                     if (this.focusChangeDirection == VisualElementFocusChangeDirection.left)
                     {
                         GUIUtility.SetKeyboardControlToLastControlId();
                     }
                     else if (this.focusChangeDirection == VisualElementFocusChangeDirection.right)
                     {
                         GUIUtility.SetKeyboardControlToFirstControlId();
                     }
                 }
                 this.receivedFocus        = false;
                 this.focusChangeDirection = FocusChangeDirection.unspecified;
                 if (this.focusController != null)
                 {
                     this.focusController.imguiKeyboardControl = GUIUtility.keyboardControl;
                 }
             }
         }
         this.GUIDepth = GUIUtility.Internal_GetGUIDepth();
         EventType type = Event.current.type;
         bool      flag = false;
         try
         {
             Matrix4x4 objectTransform;
             Rect      clipRect;
             IMGUIContainer.GetCurrentTransformAndClip(this, evt, out objectTransform, out clipRect);
             using (new GUIClip.ParentClipScope(objectTransform, clipRect))
             {
                 this.m_OnGUIHandler();
             }
         }
         catch (Exception exception)
         {
             if (type != EventType.Layout)
             {
                 throw;
             }
             flag = GUIUtility.IsExitGUIException(exception);
             if (!flag)
             {
                 Debug.LogException(exception);
             }
         }
         finally
         {
             if (evt.type != EventType.Layout)
             {
                 int keyboardControl = GUIUtility.keyboardControl;
                 int num2            = GUIUtility.CheckForTabEvent(evt);
                 if (this.focusController != null)
                 {
                     if (num2 < 0)
                     {
                         Focusable focusedElement = this.focusController.focusedElement;
                         using (KeyDownEvent pooled = KeyboardEventBase <KeyDownEvent> .GetPooled('\t', KeyCode.Tab, (num2 != -1) ? EventModifiers.Shift : EventModifiers.None))
                         {
                             this.focusController.SwitchFocusOnEvent(pooled);
                         }
                         if (focusedElement == this)
                         {
                             if (this.focusController.focusedElement == this)
                             {
                                 if (num2 == -2)
                                 {
                                     GUIUtility.SetKeyboardControlToLastControlId();
                                 }
                                 else if (num2 == -1)
                                 {
                                     GUIUtility.SetKeyboardControlToFirstControlId();
                                 }
                                 this.newKeyboardFocusControlID            = GUIUtility.keyboardControl;
                                 this.focusController.imguiKeyboardControl = GUIUtility.keyboardControl;
                             }
                             else
                             {
                                 GUIUtility.keyboardControl = 0;
                                 this.focusController.imguiKeyboardControl = 0;
                             }
                         }
                     }
                     else if (num2 > 0)
                     {
                         this.focusController.imguiKeyboardControl = GUIUtility.keyboardControl;
                         this.newKeyboardFocusControlID            = GUIUtility.keyboardControl;
                     }
                     else if (num2 == 0)
                     {
                         if (keyboardControl != GUIUtility.keyboardControl || type == EventType.MouseDown)
                         {
                             this.focusController.SyncIMGUIFocus(GUIUtility.keyboardControl, this);
                         }
                     }
                 }
                 this.hasFocusableControls = GUIUtility.HasFocusableControls();
             }
         }
         EventType type2 = Event.current.type;
         UIElementsUtility.EndContainerGUI();
         this.RestoreGlobals();
         if (!flag)
         {
             if (type2 != EventType.Ignore && type2 != EventType.Used)
             {
                 int num3 = GUIClip.Internal_GetCount();
                 if (num3 > num)
                 {
                     Debug.LogError("GUI Error: You are pushing more GUIClips than you are popping. Make sure they are balanced)");
                 }
                 else if (num3 < num)
                 {
                     Debug.LogError("GUI Error: You are popping more GUIClips than you are pushing. Make sure they are balanced)");
                 }
             }
         }
         while (GUIClip.Internal_GetCount() > num)
         {
             GUIClip.Internal_Pop();
         }
         if (type2 == EventType.Used)
         {
             base.Dirty(ChangeType.Repaint);
         }
     }
 }
        internal static EventBase CreateEvent(Event systemEvent)
        {
            EventType type = systemEvent.type;
            EventBase pooled;

            switch (type)
            {
            case EventType.MouseDown:
                pooled = MouseEventBase <MouseDownEvent> .GetPooled(systemEvent);

                break;

            case EventType.MouseUp:
                pooled = MouseEventBase <MouseUpEvent> .GetPooled(systemEvent);

                break;

            case EventType.MouseMove:
                pooled = MouseEventBase <MouseMoveEvent> .GetPooled(systemEvent);

                break;

            case EventType.MouseDrag:
                pooled = MouseEventBase <MouseMoveEvent> .GetPooled(systemEvent);

                break;

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

                break;

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

                break;

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

            default:
                if (type != EventType.MouseEnterWindow)
                {
                    if (type != EventType.MouseLeaveWindow)
                    {
                        pooled = IMGUIEvent.GetPooled(systemEvent);
                    }
                    else
                    {
                        pooled = MouseEventBase <MouseLeaveWindowEvent> .GetPooled(systemEvent);
                    }
                }
                else
                {
                    pooled = MouseEventBase <MouseEnterWindowEvent> .GetPooled(systemEvent);
                }
                break;
            }
            return(pooled);
        }