示例#1
0
 private void GoToChild(AdvancedDropdownItem parent)
 {
     m_LastTime = System.DateTime.Now.Ticks;
     if (m_NewAnimTarget < 0)
     {
         m_NewAnimTarget = 1 + m_NewAnimTarget;
     }
     else
     {
         m_NewAnimTarget = 1;
     }
     m_CurrentlyRenderedTree = parent.GetSelectedChild();
     m_AnimationTree         = parent;
 }
示例#2
0
        private void HandleKeyboard()
        {
            var evt = Event.current;

            if (evt.type == EventType.KeyDown)
            {
                // Special handling when in new script panel
                if (SpecialKeyboardHandling(evt))
                {
                    return;
                }

                // Always do these
                if (evt.keyCode == KeyCode.DownArrow)
                {
                    m_CurrentlyRenderedTree.MoveDownSelection();
                    m_ScrollToSelected = true;
                    evt.Use();
                }
                if (evt.keyCode == KeyCode.UpArrow)
                {
                    m_CurrentlyRenderedTree.MoveUpSelection();
                    m_ScrollToSelected = true;
                    evt.Use();
                }
                if (evt.keyCode == KeyCode.Return || evt.keyCode == KeyCode.KeypadEnter)
                {
                    var selected = m_CurrentlyRenderedTree.GetSelectedChild();
                    if (selected != null && selected.children.Any())
                    {
                        GoToChild(m_CurrentlyRenderedTree);
                    }
                    else
                    {
                        if (selected != null && selected.OnAction())
                        {
                            if (selectionChanged != null)
                            {
                                selectionChanged(m_CurrentlyRenderedTree.GetSelectedChild());
                            }
                            if (closeOnSelection)
                            {
                                CloseWindow();
                            }
                        }
                    }
                    evt.Use();
                }

                // Do these if we're not in search mode
                if (!hasSearch)
                {
                    if (evt.keyCode == KeyCode.LeftArrow || evt.keyCode == KeyCode.Backspace)
                    {
                        GoToParent();
                        evt.Use();
                    }
                    if (evt.keyCode == KeyCode.RightArrow)
                    {
                        var child = m_CurrentlyRenderedTree.GetSelectedChild();
                        if (child != null && child.children.Any())
                        {
                            GoToChild(m_CurrentlyRenderedTree);
                        }
                        evt.Use();
                    }
                    if (evt.keyCode == KeyCode.Escape)
                    {
                        Close();
                        evt.Use();
                    }
                }
            }
        }