Пример #1
0
        public void _reparent(FocusNode child)
        {
            D.assert(child != null);
            D.assert(child != this, () => "Tried to make a child into a parent of itself.");
            if (child._parent == this)
            {
                D.assert(_children.Contains(child),
                         () => "Found a node that says it's a child, but doesn't appear in the child list.");
                // The child is already a child of this parent.
                return;
            }

            D.assert(_manager == null || child != _manager.rootScope, () => "Reparenting the root node isn't allowed.");
            D.assert(!ancestors.Contains(child),
                     () => "The supplied child is already an ancestor of this node. Loops are not allowed.");
            FocusScopeNode oldScope = child.enclosingScope;
            bool           hadFocus = child.hasFocus;

            child._parent?._removeChild(child, removeScopeFocus: oldScope != nearestScope);
            _children.Add(child);
            child._parent    = this;
            child._ancestors = null;
            child._updateManager(_manager);
            foreach (FocusNode ancestor in child.ancestors)
            {
                ancestor._descendants = null;
            }

            if (hadFocus)
            {
                _manager?.primaryFocus?._setAsFocusedChildForScope();
            }

            if (oldScope != null && child.context != null && child.enclosingScope != oldScope)
            {
                //UnityEngine.Debug.Log("FocusTraversalGroup.of(child.context, nullOk: true)?.changedScope(node: child, oldScope: oldScope);");
                FocusTraversalGroup.of(child.context, nullOk: true)?.changedScope(node: child, oldScope: oldScope);
            }

            if (child._requestFocusWhenReparented)
            {
                child._doRequestFocus(findFirstFocus: true);
                child._requestFocusWhenReparented = false;
            }
        }
Пример #2
0
 public bool focusInDirection(TraversalDirection direction)
 {
     return(FocusTraversalGroup.of(context).inDirection(this, direction));
 }
Пример #3
0
 public bool previousFocus()
 {
     return(FocusTraversalGroup.of(context).previous(this));
 }
Пример #4
0
 public bool nextFocus()
 {
     return(FocusTraversalGroup.of(context).next(this));
 }