From b2452ecca7a9416c04686c9bcec8cab74a6af638 Mon Sep 17 00:00:00 2001 From: Federico Terzi Date: Mon, 15 Nov 2021 22:23:29 +0100 Subject: [PATCH] feat(modulo): add Esc handling in textview UI --- espanso-modulo/src/sys/textview/textview.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/espanso-modulo/src/sys/textview/textview.cpp b/espanso-modulo/src/sys/textview/textview.cpp index 7134fbf..47a65ce 100644 --- a/espanso-modulo/src/sys/textview/textview.cpp +++ b/espanso-modulo/src/sys/textview/textview.cpp @@ -42,6 +42,8 @@ class DerivedTextViewFrame : public TextViewFrame { protected: void on_copy_to_clipboard( wxCommandEvent& event ); + + void on_char_event(wxKeyEvent &event); public: DerivedTextViewFrame(wxWindow *parent); @@ -52,6 +54,16 @@ DerivedTextViewFrame::DerivedTextViewFrame(wxWindow *parent) { this->text_content->SetValue(wxString::FromUTF8(text_view_metadata->content)); this->SetTitle(wxString::FromUTF8(text_view_metadata->title)); + + + Bind(wxEVT_CHAR_HOOK, &DerivedTextViewFrame::on_char_event, this, wxID_ANY); +} + +void DerivedTextViewFrame::on_char_event(wxKeyEvent &event) { + if (event.GetKeyCode() == WXK_ESCAPE) + { + Close(true); + } } void DerivedTextViewFrame::on_copy_to_clipboard( wxCommandEvent& event ) {