Skip to content

Commit

Permalink
refactor: Button
Browse files Browse the repository at this point in the history
  • Loading branch information
BlurOne-GIT committed Mar 26, 2024
1 parent f958033 commit bbe864d
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions MmgEngine/Button.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit bbe864d

Please sign in to comment.