protected override void ExecuteDefaultActionAtTarget(EventBase evt) { base.ExecuteDefaultActionAtTarget(evt); elementPanel?.contextualMenuManager?.DisplayMenuIfEventMatches(evt, this); if (evt?.eventTypeId == ContextualMenuPopulateEvent.TypeId()) { ContextualMenuPopulateEvent e = evt as ContextualMenuPopulateEvent; int count = e.menu.MenuItems().Count; BuildContextualMenu(e); if (count > 0 && e.menu.MenuItems().Count > count) { e.menu.InsertSeparator(null, count); } } else if (evt.eventTypeId == FocusInEvent.TypeId()) { SaveValueAndText(); } else if (evt.eventTypeId == KeyDownEvent.TypeId()) { KeyDownEvent keyDownEvt = evt as KeyDownEvent; if (keyDownEvt?.keyCode == KeyCode.Escape) { RestoreValueAndText(); parent.Focus(); } } editorEventHandler.ExecuteDefaultActionAtTarget(evt); }
protected override void ExecuteDefaultActionAtTarget(EventBase evt) { base.ExecuteDefaultActionAtTarget(evt); // The following code is to help achieve the following behaviour: // On IMGUI, a TextArea "in edit mode" is accepting TAB, doing a Shift+Return will get out of the Edit mode // and 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. if (multiline) { if ((evt?.eventTypeId == FocusInEvent.TypeId() && evt?.leafTarget == this) || (evt?.eventTypeId == FocusInEvent.TypeId() && evt?.leafTarget == labelElement)) { m_VisualInputTabIndex = visualInput.tabIndex; visualInput.tabIndex = -1; } else if ((evt?.eventTypeId == BlurEvent.TypeId() && evt?.leafTarget == this) || (evt?.eventTypeId == BlurEvent.TypeId() && evt?.leafTarget == labelElement)) { visualInput.tabIndex = m_VisualInputTabIndex; } } }
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; } } }