public void MouseDown(MouseButtonEventArgs args) { // 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.Position - top.GlobalPixelPosition; if (!top.HasPoint(offset / UIScale)) { RemoveModal(top); args.Handle(); return; } } var control = MouseGetControl(args.Position); if (control == null) { ReleaseKeyboardFocus(); return; } _mouseFocused = control; if (_mouseFocused.CanKeyboardFocus && _mouseFocused.KeyboardFocusOnClick) { _mouseFocused.GrabKeyboardFocus(); } var guiArgs = new GUIMouseButtonEventArgs(args.Button, args.DoubleClick, control, Mouse.ButtonMask.None, args.Position / UIScale, args.Position, args.Position / UIScale - control.GlobalPosition, args.Position - control.GlobalPixelPosition, args.Alt, args.Control, args.Shift, args.System); _doMouseGuiInput(control, guiArgs, (c, ev) => c.MouseDown(ev)); // 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(); }
public void MouseUp(MouseButtonEventArgs args) { if (_mouseFocused == null) { return; } var guiArgs = new GUIMouseButtonEventArgs(args.Button, args.DoubleClick, _mouseFocused, Mouse.ButtonMask.None, args.Position / UIScale, args.Position, args.Position / UIScale - _mouseFocused.GlobalPosition, args.Position - _mouseFocused.GlobalPixelPosition, args.Alt, args.Control, args.Shift, args.System); _doMouseGuiInput(_mouseFocused, guiArgs, (c, ev) => c.MouseUp(ev)); _mouseFocused = 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(); }
protected internal virtual void MouseUp(GUIMouseButtonEventArgs args) { }
protected internal virtual void MouseDown(GUIMouseButtonEventArgs args) { OnMouseDown?.Invoke(args); }