public void KeyDown(KeyEventArgs args)
        {
            var control = MouseGetControl(args.PointerLocation);

            if (args.CanFocus)
            {
                // If we have a modal open and the mouse down was outside it, close said modal.
                if (_modalStack.Count != 0)
                {
                    var top    = _modalStack[_modalStack.Count - 1];
                    var offset = args.PointerLocation - top.GlobalPixelPosition.ToVector2();
                    if (!top.HasPoint(offset / UIScale))
                    {
                        RemoveModal(top);
                        return;
                    }
                }

                ReleaseKeyboardFocus();

                if (control == null)
                {
                    return;
                }

                _controlFocused = control;

                if (_controlFocused.CanKeyboardFocus && _controlFocused.KeyboardFocusOnClick)
                {
                    _controlFocused.GrabKeyboardFocus();
                }
            }
            else if (KeyboardFocused != null)
            {
                control = KeyboardFocused;
            }

            if (control == null)
            {
                return;
            }

            var guiArgs = new GUIKeyEventArgs(control, args.Key, args.State, args.PointerLocation, args.IsRepeat, args.Alt, args.Control, args.Shift, args.System);

            _doGuiInput(control, guiArgs, (c, ev) => c.KeyDown(ev));

            if (args.CanFocus)
            {
                args.Handle();
            }
        }
예제 #2
0
 protected internal virtual void KeyUp(GUIKeyEventArgs args)
 {
 }