public FocusChangeDirection GetFocusChangeDirection(Focusable currentFocusable, EventBase e)
        {
            bool flag = e == null;

            if (flag)
            {
                throw new ArgumentNullException("e");
            }
            bool flag2 = e.eventTypeId == EventBase <MouseDownEvent> .TypeId();

            FocusChangeDirection result;

            if (flag2)
            {
                Focusable focusable = e.target as Focusable;
                bool      flag3     = focusable != null;
                if (flag3)
                {
                    result = VisualElementFocusChangeTarget.GetPooled(focusable);
                    return(result);
                }
            }
            bool flag4 = currentFocusable is IMGUIContainer && e.imguiEvent != null;

            if (flag4)
            {
                result = FocusChangeDirection.none;
            }
            else
            {
                result = VisualElementFocusRing.GetKeyDownFocusChangeDirection(e);
            }
            return(result);
        }
Beispiel #2
0
 public NavigateFocusRing(VisualElement root)
 {
     m_Root = root;
     m_Ring = new VisualElementFocusRing(root);
 }
        public Focusable GetNextFocusable(Focusable currentFocusable, FocusChangeDirection direction)
        {
            bool      flag = direction == FocusChangeDirection.none || direction == FocusChangeDirection.unspecified;
            Focusable result;

            if (flag)
            {
                result = currentFocusable;
            }
            else
            {
                VisualElementFocusChangeTarget visualElementFocusChangeTarget = direction as VisualElementFocusChangeTarget;
                bool flag2 = visualElementFocusChangeTarget != null;
                if (flag2)
                {
                    result = visualElementFocusChangeTarget.target;
                }
                else
                {
                    this.DoUpdate();
                    bool flag3 = this.m_FocusRing.Count == 0;
                    if (flag3)
                    {
                        result = null;
                    }
                    else
                    {
                        int  num   = 0;
                        bool flag4 = direction == VisualElementFocusChangeDirection.right;
                        if (flag4)
                        {
                            num = this.GetFocusableInternalIndex(currentFocusable) + 1;
                            bool flag5 = currentFocusable != null && num == 0;
                            if (flag5)
                            {
                                result = VisualElementFocusRing.GetNextFocusableInTree(currentFocusable as VisualElement);
                                return(result);
                            }
                            bool flag6 = num == this.m_FocusRing.Count;
                            if (flag6)
                            {
                                num = 0;
                            }
                            while (this.m_FocusRing[num].m_Focusable.delegatesFocus)
                            {
                                num++;
                                bool flag7 = num == this.m_FocusRing.Count;
                                if (flag7)
                                {
                                    result = null;
                                    return(result);
                                }
                            }
                        }
                        else
                        {
                            bool flag8 = direction == VisualElementFocusChangeDirection.left;
                            if (flag8)
                            {
                                num = this.GetFocusableInternalIndex(currentFocusable) - 1;
                                bool flag9 = currentFocusable != null && num == -2;
                                if (flag9)
                                {
                                    result = VisualElementFocusRing.GetPreviousFocusableInTree(currentFocusable as VisualElement);
                                    return(result);
                                }
                                bool flag10 = num < 0;
                                if (flag10)
                                {
                                    num = this.m_FocusRing.Count - 1;
                                }
                                while (this.m_FocusRing[num].m_Focusable.delegatesFocus)
                                {
                                    num--;
                                    bool flag11 = num == -1;
                                    if (flag11)
                                    {
                                        result = null;
                                        return(result);
                                    }
                                }
                            }
                        }
                        result = this.m_FocusRing[num].m_Focusable;
                    }
                }
            }
            return(result);
        }