From 616379c54b5f0306645d29bd1450b47329b2f330 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Mon, 24 Oct 2022 14:00:56 -0500 Subject: [PATCH 1/2] Added an event to subscribe to in TextBoxBase that gets fired when a key is down. --- Source/Engine/UI/GUI/Common/TextBoxBase.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/Engine/UI/GUI/Common/TextBoxBase.cs b/Source/Engine/UI/GUI/Common/TextBoxBase.cs index 41d8b9b44..0930fa138 100644 --- a/Source/Engine/UI/GUI/Common/TextBoxBase.cs +++ b/Source/Engine/UI/GUI/Common/TextBoxBase.cs @@ -129,6 +129,11 @@ namespace FlaxEngine.GUI /// public event Action TextBoxEditEnd; + /// + /// Event fired when a key is down. + /// + public event Action KeyDown; + /// /// Gets or sets a value indicating whether this is a multiline text box control. /// @@ -1174,6 +1179,7 @@ namespace FlaxEngine.GUI var window = Root; bool shiftDown = window.GetKey(KeyboardKeys.Shift); bool ctrDown = window.GetKey(KeyboardKeys.Control); + KeyDown?.Invoke(key); switch (key) { From a79b64261398216f40f2dc6126a0b8c11cf2a01a Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Mon, 24 Oct 2022 14:11:34 -0500 Subject: [PATCH 2/2] Added KeyUp event in TextBoxBase --- Source/Engine/UI/GUI/Common/TextBoxBase.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Source/Engine/UI/GUI/Common/TextBoxBase.cs b/Source/Engine/UI/GUI/Common/TextBoxBase.cs index 0930fa138..92ea513a6 100644 --- a/Source/Engine/UI/GUI/Common/TextBoxBase.cs +++ b/Source/Engine/UI/GUI/Common/TextBoxBase.cs @@ -134,6 +134,11 @@ namespace FlaxEngine.GUI /// public event Action KeyDown; + /// + /// Event fired when a key is up. + /// + public event Action KeyUp; + /// /// Gets or sets a value indicating whether this is a multiline text box control. /// @@ -1173,6 +1178,13 @@ namespace FlaxEngine.GUI return true; } + /// + public override void OnKeyUp(KeyboardKeys key) + { + base.OnKeyUp(key); + KeyUp?.Invoke(key); + } + /// public override bool OnKeyDown(KeyboardKeys key) {