Gruppe22.Client.Window.ChangeFocus C# (CSharp) Method

ChangeFocus() public method

public ChangeFocus ( bool forward = true ) : void
forward bool
return void
        public void ChangeFocus(bool forward = true)
        {
            if (_children.Count > _focusID)
            {
                _children[_focusID].focus = false;
                int current = _focusID;
                for (int count = 0; count < _children.Count; ++count)
                {
                    if (forward)
                    {
                        current += 1;
                    }
                    else
                    {
                        current -= 1;
                    }
                    if (current == _children.Count)
                        current = 0;
                    if (current < 0)
                    {
                        current = _children.Count - 1;
                    }
                    if (_children[current].canFocus)
                    {
                        _children[current].focus = true;
                        _focusID = current;
                        return;
                    }
                }
            }
        }