From c62952ea3afd2d81ba3f703491525c5249b79cac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Brandst=C3=B6tter?= Date: Sat, 4 May 2024 16:01:31 +0200 Subject: [PATCH] Invoke the registered Action when a stateful item is right clicked --- .../Graphics/UserInterface/DrawableStatefulMenuItem.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/osu.Game/Graphics/UserInterface/DrawableStatefulMenuItem.cs b/osu.Game/Graphics/UserInterface/DrawableStatefulMenuItem.cs index 000a2f9f91..0c4e575621 100644 --- a/osu.Game/Graphics/UserInterface/DrawableStatefulMenuItem.cs +++ b/osu.Game/Graphics/UserInterface/DrawableStatefulMenuItem.cs @@ -4,6 +4,8 @@ using osu.Framework.Bindables; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics; +using osu.Framework.Input.Events; +using osuTK.Input; using osuTK; namespace osu.Game.Graphics.UserInterface @@ -19,8 +21,16 @@ namespace osu.Game.Graphics.UserInterface protected override TextContainer CreateTextContainer() => new ToggleTextContainer(Item); + protected override bool OnMouseDown(MouseDownEvent e) { + if (!IsActionable) + return true; + if (e.Button != MouseButton.Right) + return true; + + Item.Action.Value?.Invoke(); + return true; } private partial class ToggleTextContainer : TextContainer