static void ReleaseFocus(Focusable focusable, Focusable willGiveFocusTo, FocusChangeDirection direction)
 {
     using (BlurEvent e = BlurEvent.GetPooled(focusable, willGiveFocusTo, direction))
     {
         UIElementsUtility.eventDispatcher.DispatchEvent(e, null);
     }
 }
        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;
            }
        }
        private static void ReleaseFocus(Focusable focusable, Focusable willGiveFocusTo, FocusChangeDirection direction)
        {
            BlurEvent pooled = FocusEventBase <BlurEvent> .GetPooled(focusable, willGiveFocusTo, direction);

            UIElementsUtility.eventDispatcher.DispatchEvent(pooled, null);
            EventBase <BlurEvent> .ReleasePooled(pooled);
        }
示例#4
0
 void ReleaseFocus(Focusable focusable, Focusable willGiveFocusTo, FocusChangeDirection direction)
 {
     using (BlurEvent e = BlurEvent.GetPooled(focusable, willGiveFocusTo, direction, this))
     {
         focusable.SendEvent(e);
     }
 }
示例#5
0
        protected internal override void ExecuteDefaultAction(EventBase evt)
        {
            base.ExecuteDefaultAction(evt);

            if (evt.GetEventTypeId() == MouseOverEvent.TypeId() || evt.GetEventTypeId() == MouseOutEvent.TypeId())
            {
                UpdateCursorStyle(evt.GetEventTypeId());
            }
            else if (evt.GetEventTypeId() == MouseEnterEvent.TypeId())
            {
                pseudoStates |= PseudoStates.Hover;
            }
            else if (evt.GetEventTypeId() == MouseLeaveEvent.TypeId())
            {
                pseudoStates &= ~PseudoStates.Hover;
            }
            else if (evt.GetEventTypeId() == BlurEvent.TypeId())
            {
                pseudoStates = pseudoStates & ~PseudoStates.Focus;
            }
            else if (evt.GetEventTypeId() == FocusEvent.TypeId())
            {
                pseudoStates = pseudoStates | PseudoStates.Focus;
            }
        }
        protected internal override void ExecuteDefaultAction(EventBase evt)
        {
            base.ExecuteDefaultAction(evt);

            if (isDelayed && evt.GetEventTypeId() == BlurEvent.TypeId())
            {
                value = text;
            }
        }
        protected internal override void ExecuteDefaultAction(EventBase evt)
        {
            base.ExecuteDefaultAction(evt);

            if (!isDelayed || evt.GetEventTypeId() == BlurEvent.TypeId())
            {
                SetValueAndNotify(text);
            }
        }
 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;
     }
 }
示例#9
0
 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;
     }
 }
示例#10
0
        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++;
                }
            }
        }
示例#11
0
 private void OnBlur(BlurEvent evt)
 {
     base.OnLostFocus();
 }