From 671c6413cf1fcf1a6f441d9c230c1e12db6876f3 Mon Sep 17 00:00:00 2001 From: Stone_Red <56473591+Stone-Red-Code@users.noreply.github.com> Date: Fri, 12 Jun 2026 15:18:14 +0200 Subject: [PATCH] Add click event to Button and checked changed event to CheckBox --- UI/GUI/UIEelements/Controls/Button.cs | 7 +++++++ UI/GUI/UIEelements/Controls/CheckBox.cs | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/UI/GUI/UIEelements/Controls/Button.cs b/UI/GUI/UIEelements/Controls/Button.cs index 331cf0b..b2f1245 100644 --- a/UI/GUI/UIEelements/Controls/Button.cs +++ b/UI/GUI/UIEelements/Controls/Button.cs @@ -4,6 +4,8 @@ namespace RemSox.UI.GUI.UIEelements.Controls; public class Button() : Control("Button") { + public event EventHandler? OnClick; + public string Text { get; @@ -15,4 +17,9 @@ public class Button() : Control("Button") get; set => SetProperty(nameof(TextColor), ref field, value); } = Color.Black; + + public void Click() + { + OnClick?.Invoke(this, EventArgs.Empty); + } } \ No newline at end of file diff --git a/UI/GUI/UIEelements/Controls/CheckBox.cs b/UI/GUI/UIEelements/Controls/CheckBox.cs index f6539fb..d38fe5b 100644 --- a/UI/GUI/UIEelements/Controls/CheckBox.cs +++ b/UI/GUI/UIEelements/Controls/CheckBox.cs @@ -4,10 +4,16 @@ namespace RemSox.UI.GUI.UIEelements.Controls; public class CheckBox() : Control("CheckBox") { + public event EventHandler? OnCheckedChanged; + public bool IsChecked { get; - set => SetProperty(nameof(IsChecked), ref field, value); + set + { + SetProperty(nameof(IsChecked), ref field, value); + OnCheckedChanged?.Invoke(this, EventArgs.Empty); + } } = false; public string Text