Skip to content
This repository was archived by the owner on Sep 21, 2023. It is now read-only.

Commit 2b31324

Browse files
author
Alexis Huvier
committed
feat(event): Use ValueEventArgs to Checkbox
1 parent 3ed46c0 commit 2b31324

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

SharpEngine/Widget/Checkbox.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Raylib_cs;
33
using SharpEngine.Manager;
44
using SharpEngine.Math;
5+
using SharpEngine.Utils.EventArgs;
56
using Color = SharpEngine.Utils.Color;
67
using MouseButton = SharpEngine.Utils.Input.MouseButton;
78

@@ -25,7 +26,7 @@ public class Checkbox: Widget
2526
/// <summary>
2627
/// Event trigger when value is changed
2728
/// </summary>
28-
public event EventHandler? ValueChanged;
29+
public event EventHandler<ValueEventArgs<bool>>? ValueChanged;
2930

3031
/// <summary>
3132
/// Create Checkbox
@@ -49,8 +50,12 @@ public override void Update(float delta)
4950
if (InputManager.IsMouseButtonPressed(MouseButton.Left) &&
5051
InputManager.IsMouseInRectangle(new Rect(RealPosition - Size / 2, Size)))
5152
{
52-
ValueChanged?.Invoke(this, EventArgs.Empty);
5353
IsChecked = !IsChecked;
54+
ValueChanged?.Invoke(this, new ValueEventArgs<bool>()
55+
{
56+
OldValue = !IsChecked,
57+
NewValue = IsChecked
58+
});
5459
}
5560
}
5661

0 commit comments

Comments
 (0)