From 66ffd9969669610f22dccfdaee439326b3372f9a Mon Sep 17 00:00:00 2001 From: Tristan 'Natrist' Cormier Date: Sun, 5 Oct 2025 11:46:18 -0400 Subject: [PATCH] feat(ui): handle escape key events in CSimpleEditBox (#103) Co-authored-by: fallenoak --- src/ui/CSimpleEditBox.cpp | 9 ++++++++- src/ui/CSimpleEditBox.hpp | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ui/CSimpleEditBox.cpp b/src/ui/CSimpleEditBox.cpp index 5ad17f7..2434821 100644 --- a/src/ui/CSimpleEditBox.cpp +++ b/src/ui/CSimpleEditBox.cpp @@ -765,7 +765,8 @@ void CSimpleEditBox::OnEnterPressed() { } void CSimpleEditBox::OnEscapePressed() { - // TODO + this->RunOnEscapePressedScript(); + // TODO this->DispatchAction(EVENT_ESCAPE); } void CSimpleEditBox::OnTabPressed() { @@ -1028,6 +1029,12 @@ void CSimpleEditBox::RunOnEnterPressedScript() { } } +void CSimpleEditBox::RunOnEscapePressedScript() { + if (this->m_onEscapePressed.luaRef) { + this->RunScript(this->m_onEscapePressed, 0, nullptr); + } +} + void CSimpleEditBox::RunOnTabPressedScript() { if (this->m_onTabPressed.luaRef) { this->RunScript(this->m_onTabPressed, 0, nullptr); diff --git a/src/ui/CSimpleEditBox.hpp b/src/ui/CSimpleEditBox.hpp index 3f8fed9..2cd93c4 100644 --- a/src/ui/CSimpleEditBox.hpp +++ b/src/ui/CSimpleEditBox.hpp @@ -100,6 +100,7 @@ class CSimpleEditBox : public CSimpleFrame, CSimpleFontedFrame { void RunOnEditFocusGainedScript(); void RunOnEditFocusLostScript(); void RunOnEnterPressedScript(); + void RunOnEscapePressedScript(); void RunOnTabPressedScript(); void RunOnTextChangedScript(int32_t changed); void SetCursorPosition(int32_t position);