From bbe864df74795e5264219e8bf49f816cb0ee34c0 Mon Sep 17 00:00:00 2001 From: BlurOne! <61806094+BlurOne-GIT@users.noreply.github.com> Date: Tue, 26 Mar 2024 09:16:49 -0300 Subject: [PATCH] refactor: Button --- MmgEngine/Button.cs | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/MmgEngine/Button.cs b/MmgEngine/Button.cs index 87ee889..2557d45 100644 --- a/MmgEngine/Button.cs +++ b/MmgEngine/Button.cs @@ -55,29 +55,26 @@ public override void Draw(GameTime gameTime) private void Check(object s, ButtonEventArgs e) { - if (!Enabled) + if (!Enabled || !ActionBox.Contains(e.Position)) return; - - if (ActionBox.Contains(e.Position)) + + switch (e.Button) { - switch (e.Button) - { - case "LeftButton": - LeftClicked?.Invoke(this, new EventArgs()); - break; - case "MiddleButton": - MiddleClicked?.Invoke(this, new EventArgs()); - break; - case "RightButton": - RightClicked?.Invoke(this, new EventArgs()); - break; - case "XButton1": - XButton1Clicked?.Invoke(this, new EventArgs()); - break; - case "XButton2": - XButton2Clicked?.Invoke(this, new EventArgs()); - break; - } + case "LeftButton": + LeftClicked?.Invoke(this, EventArgs.Empty); + break; + case "MiddleButton": + MiddleClicked?.Invoke(this, EventArgs.Empty); + break; + case "RightButton": + RightClicked?.Invoke(this, EventArgs.Empty); + break; + case "XButton1": + XButton1Clicked?.Invoke(this, EventArgs.Empty); + break; + case "XButton2": + XButton2Clicked?.Invoke(this, EventArgs.Empty); + break; } }