internal Focusable FocusNextInDirection(FocusChangeDirection direction)
        {
            Focusable f = focusRing.GetNextFocusable(GetLeafFocusedElement(), direction);

            direction.ApplyTo(this, f);
            return(f);
        }
        internal Focusable SwitchFocusOnEvent(EventBase e)
        {
            bool      processedByFocusController = e.processedByFocusController;
            Focusable result;

            if (processedByFocusController)
            {
                result = this.GetLeafFocusedElement();
            }
            else
            {
                using (FocusChangeDirection focusChangeDirection = this.focusRing.GetFocusChangeDirection(this.GetLeafFocusedElement(), e))
                {
                    bool flag = focusChangeDirection != FocusChangeDirection.none;
                    if (flag)
                    {
                        Focusable nextFocusable = this.focusRing.GetNextFocusable(this.GetLeafFocusedElement(), focusChangeDirection);
                        focusChangeDirection.ApplyTo(this, nextFocusable);
                        e.processedByFocusController = true;
                        result = nextFocusable;
                        return(result);
                    }
                }
                result = this.GetLeafFocusedElement();
            }
            return(result);
        }
        internal Focusable SwitchFocusOnEvent(EventBase e)
        {
            if (e.processedByFocusController)
            {
                return(GetLeafFocusedElement());
            }

            using (FocusChangeDirection direction = focusRing.GetFocusChangeDirection(GetLeafFocusedElement(), e))
            {
                if (direction != FocusChangeDirection.none)
                {
                    Focusable f = focusRing.GetNextFocusable(GetLeafFocusedElement(), direction);
                    direction.ApplyTo(this, f);
                    e.processedByFocusController = true;
                    // f does not have the focus yet. It will when the series of focus events will have been handled.
                    return(f);
                }
            }

            return(GetLeafFocusedElement());
        }