protected internal override void ExecuteDefaultAction(EventBase evt) { if (evt.GetEventTypeId() == EventBase <BlurEvent> .TypeId()) { BlurEvent blurEvent = evt as BlurEvent; if (blurEvent.relatedTarget == null || !blurEvent.relatedTarget.canGrabFocus) { this.lostFocus = true; } } else if (evt.GetEventTypeId() == EventBase <FocusEvent> .TypeId()) { FocusEvent focusEvent = evt as FocusEvent; this.receivedFocus = true; this.focusChangeDirection = focusEvent.direction; } }
protected internal override void ExecuteDefaultAction(EventBase evt) { // 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.GetEventTypeId() == BlurEvent.TypeId()) { BlurEvent be = evt as BlurEvent; VisualElement relatedTargetElement = be.relatedTarget as VisualElement; // To mimic IMGUI behavior, we only want to clear GUIUtility.keyboardControl // when there is something else actually taking focus (canGrabFocus == true) // or when the clicked element is the top level IMGUIContainer (relatedTargetElement.parent == panel.visualTree). if (relatedTargetElement != null && (be.relatedTarget.canGrabFocus || relatedTargetElement.parent == panel.visualTree)) { lostFocus = true; } } else if (evt.GetEventTypeId() == FocusEvent.TypeId()) { FocusEvent fe = evt as FocusEvent; receivedFocus = true; focusChangeDirection = fe.direction; } else if (evt.GetEventTypeId() == DetachFromPanelEvent.TypeId()) { if (elementPanel != null) { elementPanel.IMGUIContainersCount--; } } else if (evt.GetEventTypeId() == AttachToPanelEvent.TypeId()) { if (elementPanel != null) { elementPanel.IMGUIContainersCount++; } } }
protected internal override void ExecuteDefaultAction(EventBase evt) { if (evt.GetEventTypeId() == EventBase <BlurEvent> .TypeId()) { BlurEvent blurEvent = evt as BlurEvent; VisualElement visualElement = blurEvent.relatedTarget as VisualElement; if (visualElement != null && (blurEvent.relatedTarget.canGrabFocus || visualElement.parent == base.panel.visualTree)) { this.lostFocus = true; } } else if (evt.GetEventTypeId() == EventBase <FocusEvent> .TypeId()) { FocusEvent focusEvent = evt as FocusEvent; this.receivedFocus = true; this.focusChangeDirection = focusEvent.direction; } }
protected internal override void ExecuteDefaultAction(EventBase evt) { // 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.GetEventTypeId() == 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; } else if (evt.GetEventTypeId() == FocusEvent.TypeId()) { FocusEvent fe = evt as FocusEvent; receivedFocus = true; focusChangeDirection = fe.direction; } else if (evt.GetEventTypeId() == DetachFromPanelEvent.TypeId()) { if (elementPanel != null) { elementPanel.IMGUIContainersCount--; } } else if (evt.GetEventTypeId() == AttachToPanelEvent.TypeId()) { if (elementPanel != null) { elementPanel.IMGUIContainersCount++; } } }
private void OnFocus(FocusEvent evt) { base.OnFocus(); }