From 06d63cdab87cdbd013daabe103b64a849b896ee7 Mon Sep 17 00:00:00 2001 From: Tristan Cormier Date: Sat, 4 Oct 2025 18:30:21 -0400 Subject: [PATCH] feat(CSimpleEditBox): implement OnEscapePressed event handler --- 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 2716084..b9dbc75 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::OnFrameSizeChanged(float width, float height) { @@ -1019,6 +1020,12 @@ void CSimpleEditBox::RunOnEnterPressedScript() { } } +void CSimpleEditBox::RunOnEscapePressedScript() { + if (this->m_onEscapePressed.luaRef) { + this->RunScript(this->m_onEscapePressed, 0, nullptr); + } +} + void CSimpleEditBox::RunOnTextChangedScript(int32_t changed) { if (this->m_onTextChanged.luaRef) { auto L = FrameScript_GetContext(); diff --git a/src/ui/CSimpleEditBox.hpp b/src/ui/CSimpleEditBox.hpp index 1272e8f..80fc460 100644 --- a/src/ui/CSimpleEditBox.hpp +++ b/src/ui/CSimpleEditBox.hpp @@ -99,6 +99,7 @@ class CSimpleEditBox : public CSimpleFrame, CSimpleFontedFrame { void RunOnEditFocusGainedScript(); void RunOnEditFocusLostScript(); void RunOnEnterPressedScript(); + void RunOnEscapePressedScript(); void RunOnTextChangedScript(int32_t changed); void SetCursorPosition(int32_t position); void SetHistoryLines(int32_t a2);