private void SwitchFocus(Focusable newFocusedElement, FocusChangeDirection direction)
 {
     if (newFocusedElement != this.focusedElement)
     {
         Focusable focusedElement = this.focusedElement;
         if (newFocusedElement == null || !newFocusedElement.canGrabFocus)
         {
             if (focusedElement != null)
             {
                 FocusController.AboutToReleaseFocus(focusedElement, newFocusedElement, direction);
                 this.focusedElement = null;
                 FocusController.ReleaseFocus(focusedElement, newFocusedElement, direction);
             }
         }
         else if (newFocusedElement != focusedElement)
         {
             if (focusedElement != null)
             {
                 FocusController.AboutToReleaseFocus(focusedElement, newFocusedElement, direction);
             }
             FocusController.AboutToGrabFocus(newFocusedElement, focusedElement, direction);
             this.focusedElement = newFocusedElement;
             if (focusedElement != null)
             {
                 FocusController.ReleaseFocus(focusedElement, newFocusedElement, direction);
             }
             FocusController.GrabFocus(newFocusedElement, focusedElement, direction);
         }
     }
 }
Example #2
0
        public Panel(ScriptableObject ownerObject, ContextType contextType, IDataWatchService dataWatch = null, IEventDispatcher dispatcher = null)
        {
            this.ownerObject               = ownerObject;
            this.contextType               = contextType;
            m_DataWatch                    = dataWatch;
            this.dispatcher                = dispatcher;
            stylePainter                   = new StylePainter();
            cursorManager                  = new CursorManager();
            contextualMenuManager          = null;
            m_RootContainer                = new VisualElement();
            m_RootContainer.name           = VisualElementUtils.GetUniqueName("PanelContainer");
            m_RootContainer.persistenceKey = "PanelContainer"; // Required!
            visualTree.SetPanel(this);
            focusController = new FocusController(new VisualElementFocusRing(visualTree));
            m_StyleContext  = new StyleSheets.StyleContext(m_RootContainer);

            allowPixelCaching = true;
        }
Example #3
0
        public Panel(ScriptableObject ownerObject, ContextType contextType, IDataWatchService dataWatch = null, EventDispatcher dispatcher = null)
        {
            m_VisualTreeUpdater = new VisualTreeUpdater(this);

            this.ownerObject               = ownerObject;
            this.contextType               = contextType;
            m_DataWatch                    = dataWatch;
            this.dispatcher                = dispatcher ?? EventDispatcher.instance;
            repaintData                    = new RepaintData();
            cursorManager                  = new CursorManager();
            contextualMenuManager          = null;
            m_RootContainer                = new VisualElement();
            m_RootContainer.name           = VisualElementUtils.GetUniqueName("PanelContainer");
            m_RootContainer.persistenceKey = "PanelContainer"; // Required!
            visualTree.SetPanel(this);
            focusController       = new FocusController(new VisualElementFocusRing(visualTree));
            m_ProfileUpdateName   = "PanelUpdate";
            m_ProfileLayoutName   = "PanelLayout";
            m_ProfileBindingsName = "PanelBindings";

            allowPixelCaching = true;
        }