public void MouseButtonDown(MouseButtonEventArgs 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 GUIMouseButtonEventArgs(args.Button, args.State, control, args.Position / UIScale,
                                                      args.Position, args.Position / UIScale - control.GlobalPosition,
                                                      args.Position - control.GlobalPixelPosition.ToVector2());

            _doMouseGuiInput(control, guiArgs, (c, ev) => c.MouseButtonDown(ev));

            if (args.CanFocus)
            {
                args.Handle();
            }
        }
        public void MouseButtonUp(MouseButtonEventArgs args)
        {
            var control = _controlFocused ?? KeyboardFocused ?? MouseGetControl(args.PointerLocation);

            if (control == null)
            {
                return;
            }

            var guiArgs = new GUIMouseButtonEventArgs(args.Button, args.State, control, args.Position / UIScale,
                                                      args.Position, args.Position / UIScale - control.GlobalPosition,
                                                      args.Position - control.GlobalPixelPosition.ToVector2());

            _doMouseGuiInput(control, guiArgs, (c, ev) => c.MouseButtonUp(ev));
            _controlFocused = null;

            // Always mark this as handled.
            // The only case it should not be is if we do not have a control to click on,
            // in which case we never reach this.
            args.Handle();
        }
Ejemplo n.º 3
0
 protected internal virtual void MouseButtonUp(GUIMouseButtonEventArgs args)
 {
 }
Ejemplo n.º 4
0
 protected internal virtual void MouseButtonDown(GUIMouseButtonEventArgs args)
 {
     OnMouseButtonDown?.Invoke(args);
 }