Esempio n. 1
0
        protected internal virtual void       OnPadMove(Direction _direction)
        {
            Widget widget = GetSibling(_direction, this);

            if (widget != null)
            {
                Widget focusableWidget = widget.GetFirstFocusableDescendant(_direction);

                if (focusableWidget != null)
                {
                    Screen.Focus(focusableWidget);
                }
            }
        }
Esempio n. 2
0
        protected internal virtual void OnOSKeyPress(OSKey _key)
        {
            bool bCtrl = Screen.Game.InputMgr.KeyboardState.IsKeyDown(Keys.LeftControl, true) || Screen.Game.InputMgr.KeyboardState.IsKeyDown(Keys.RightControl, true);

            if (!bCtrl && _key == OSKey.Tab)
            {
                List <Direction> directions = new List <Direction>();

                if (Screen.Game.InputMgr.KeyboardState.Native.IsKeyDown(Keys.LeftShift) || Screen.Game.InputMgr.KeyboardState.Native.IsKeyDown(Keys.RightShift))
                {
                    directions.Add(Direction.Left);
                    directions.Add(Direction.Up);
                }
                else
                {
                    directions.Add(Direction.Right);
                    directions.Add(Direction.Down);
                }

                foreach (Direction direction in directions)
                {
                    Widget widget = GetSibling(direction, this);

                    if (widget != null)
                    {
                        Widget focusableWidget = widget.GetFirstFocusableDescendant(direction);

                        if (focusableWidget != null)
                        {
                            Screen.Focus(focusableWidget);
                            break;
                        }
                    }
                }
            }
            else
            {
                if (Parent != null)
                {
                    Parent.OnOSKeyPress(_key);
                }
            }
        }
Esempio n. 3
0
        public override Widget GetFirstFocusableDescendant(Direction _direction)
        {
            switch (_direction)
            {
            case Direction.Left:
                for (int i = maTiles.GetLength(0) - 1; i >= 0; i--)
                {
                    for (int j = 0; j < maTiles.GetLength(1); j++)
                    {
                        Widget widget = maTiles[i, j];
                        if (widget != null)
                        {
                            Widget focusableWidget = widget.GetFirstFocusableDescendant(_direction);
                            if (focusableWidget != null)
                            {
                                return(focusableWidget);
                            }
                        }
                    }
                }
                break;

            case Direction.Right:
                for (int i = 0; i < maTiles.GetLength(0); i++)
                {
                    for (int j = 0; j < maTiles.GetLength(1); j++)
                    {
                        Widget widget = maTiles[i, j];
                        if (widget != null)
                        {
                            Widget focusableWidget = widget.GetFirstFocusableDescendant(_direction);
                            if (focusableWidget != null)
                            {
                                return(focusableWidget);
                            }
                        }
                    }
                }
                break;

            case Direction.Up:
                for (int j = maTiles.GetLength(1) - 1; j >= 0; j--)
                {
                    for (int i = 0; i < maTiles.GetLength(0); i++)
                    {
                        Widget widget = maTiles[i, j];
                        if (widget != null)
                        {
                            Widget focusableWidget = widget.GetFirstFocusableDescendant(_direction);
                            if (focusableWidget != null)
                            {
                                return(focusableWidget);
                            }
                        }
                    }
                }
                break;

            case Direction.Down:
                for (int j = 0; j < maTiles.GetLength(1); j++)
                {
                    for (int i = 0; i < maTiles.GetLength(0); i++)
                    {
                        Widget widget = maTiles[i, j];
                        if (widget != null)
                        {
                            Widget focusableWidget = widget.GetFirstFocusableDescendant(_direction);
                            if (focusableWidget != null)
                            {
                                return(focusableWidget);
                            }
                        }
                    }
                }
                break;
            }

            return(null);
        }