Example #1
0
        protected override void ExecuteDefaultAction(EventBase evt)
        {
            bool flag = evt == null;

            if (!flag)
            {
                bool flag2 = evt.eventTypeId == EventBase <BlurEvent> .TypeId();

                if (flag2)
                {
                    this.lostFocus = true;
                    base.IncrementVersion(VersionChangeType.Repaint);
                }
                else
                {
                    bool flag3 = evt.eventTypeId == EventBase <FocusEvent> .TypeId();

                    if (flag3)
                    {
                        FocusEvent focusEvent = evt as FocusEvent;
                        this.receivedFocus        = true;
                        this.focusChangeDirection = focusEvent.direction;
                        this.m_IsFocusDelegated   = focusEvent.IsFocusDelegated;
                    }
                    else
                    {
                        bool flag4 = evt.eventTypeId == EventBase <DetachFromPanelEvent> .TypeId();

                        if (flag4)
                        {
                            bool flag5 = base.elementPanel != null;
                            if (flag5)
                            {
                                BaseVisualElementPanel expr_9F = base.elementPanel;
                                int iMGUIContainersCount       = expr_9F.IMGUIContainersCount;
                                expr_9F.IMGUIContainersCount = iMGUIContainersCount - 1;
                            }
                        }
                        else
                        {
                            bool flag6 = evt.eventTypeId == EventBase <AttachToPanelEvent> .TypeId();

                            if (flag6)
                            {
                                bool flag7 = base.elementPanel != null;
                                if (flag7)
                                {
                                    BaseVisualElementPanel expr_DF = base.elementPanel;
                                    int iMGUIContainersCount       = expr_DF.IMGUIContainersCount;
                                    expr_DF.IMGUIContainersCount = iMGUIContainersCount + 1;
                                }
                            }
                        }
                    }
                }
            }
        }
        void OnFocus(FocusEvent _)
        {
            GUIUtility.imeCompositionMode = IMECompositionMode.On;
            m_DragToPosition = false;

            // If focus was given to this element from a mouse click or a Panel.Focus call, allow select on mouse up.
            if (PointerDeviceState.GetPressedButtons(PointerId.mousePointerId) != 0 ||
                (textInputField as VisualElement)?.panel.contextType == ContextType.Editor && Event.current == null)
            {
                m_SelectAllOnMouseUp = true;
            }
        }
Example #3
0
        protected override void ExecuteDefaultAction(EventBase evt)
        {
            if (evt == null)
            {
                return;
            }

            // no call to base.ExecuteDefaultAction(evt):
            // - we dont want mouse click to directly give focus to IMGUIContainer:
            //   they should be handled by IMGUI and if an IMGUI control grabs the
            //   keyboard, the IMGUIContainer will gain focus via FocusController.SyncIMGUIFocus.
            // - same thing for tabs: IMGUI should handle them.
            // - we dont want to set the PseudoState.Focus flag on IMGUIContainer.
            //   They are focusable, but only for the purpose of focusing their children.

            // Here, we set flags that will be acted upon in DoOnGUI(), since we need to change IMGUI state.
            if (evt.eventTypeId == BlurEvent.TypeId())
            {
                // A lost focus event is ... a lost focus event.
                // The specific handling of the IMGUI will be done in the DoOnGUI() above...
                lostFocus = true;

                // On lost focus, we need to repaint to remove any focused element blue borders.
                IncrementVersion(VersionChangeType.Repaint);
            }
            else if (evt.eventTypeId == FocusEvent.TypeId())
            {
                FocusEvent fe = evt as FocusEvent;
                receivedFocus        = true;
                focusChangeDirection = fe.direction;
                m_IsFocusDelegated   = fe.IsFocusDelegated;
            }
            else if (evt.eventTypeId == DetachFromPanelEvent.TypeId())
            {
                if (elementPanel != null)
                {
                    elementPanel.IMGUIContainersCount--;
                }
            }
            else if (evt.eventTypeId == AttachToPanelEvent.TypeId())
            {
                if (elementPanel != null)
                {
                    elementPanel.IMGUIContainersCount++;

                    // Set class names for foldout depth.
                    SetFoldoutDepthClass();
                }
            }
        }
Example #4
0
        public override void ExecuteDefaultActionAtTarget(EventBase evt)
        {
            base.ExecuteDefaultActionAtTarget(evt);

            if (evt.eventTypeId == FocusEvent.TypeId())
            {
                OnFocus(evt as FocusEvent);
            }
            else if (evt.eventTypeId == BlurEvent.TypeId())
            {
                OnBlur(evt as BlurEvent);
            }
            else if (evt.eventTypeId == MouseDownEvent.TypeId())
            {
                OnMouseDown(evt as MouseDownEvent);
            }
            else if (evt.eventTypeId == MouseUpEvent.TypeId())
            {
                OnMouseUp(evt as MouseUpEvent);
            }
            else if (evt.eventTypeId == MouseMoveEvent.TypeId())
            {
                OnMouseMove(evt as MouseMoveEvent);
            }
            else if (evt.eventTypeId == KeyDownEvent.TypeId())
            {
                OnKeyDown(evt as KeyDownEvent);
            }
            else if (evt.eventTypeId == ValidateCommandEvent.TypeId())
            {
                OnValidateCommandEvent(evt as ValidateCommandEvent);
            }
            else if (evt.eventTypeId == ExecuteCommandEvent.TypeId())
            {
                OnExecuteCommandEvent(evt as ExecuteCommandEvent);
            }
        }
Example #5
0
 void OnFocus(FocusEvent _)
 {
     GUIUtility.imeCompositionMode = IMECompositionMode.On;
     m_DragToPosition = false;
 }
 void OnFocus(FocusEvent _)
 {
     GUIUtility.imeCompositionMode = IMECompositionMode.On;
     textElement.edition.SaveValueAndText();
 }
Example #7
0
 void OnFocus(FocusEvent _)
 {
     m_DragToPosition = false;
 }
        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;
                }
            }
        }