From 2c58dd68ba2c438d314a0a5c3ed74615b46ba29e Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Sun, 7 Feb 2016 11:08:26 +0100 Subject: [PATCH] Abort added --- ZRCola/zrcolaframe.cpp | 20 +++++++++++++++++++- ZRCola/zrcolaframe.h | 2 ++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/ZRCola/zrcolaframe.cpp b/ZRCola/zrcolaframe.cpp index 5f44d57..30178ec 100644 --- a/ZRCola/zrcolaframe.cpp +++ b/ZRCola/zrcolaframe.cpp @@ -28,6 +28,7 @@ wxBEGIN_EVENT_TABLE(wxZRColaFrame, wxAppBarFrame) EVT_TEXT (wxZRColaFrame::wxID_COMPOSER, wxZRColaFrame::OnCompose ) EVT_UPDATE_UI(wxZRColaFrame::wxID_SEND , wxZRColaFrame::OnSendUpdate) EVT_MENU (wxZRColaFrame::wxID_SEND , wxZRColaFrame::OnSend ) + EVT_MENU (wxZRColaFrame::wxID_ABORT , wxZRColaFrame::OnAbort ) EVT_MENU ( wxID_ABOUT , wxZRColaFrame::OnAbout ) wxEND_EVENT_TABLE() @@ -76,8 +77,9 @@ bool wxZRColaFrame::Create() // Register frame specific hotkey(s). { - wxAcceleratorEntry entries[1]; + wxAcceleratorEntry entries[2]; entries[0].Set(wxACCEL_NORMAL, WXK_RETURN, wxID_SEND); + entries[1].Set(wxACCEL_NORMAL, WXK_ESCAPE, wxID_ABORT); SetAcceleratorTable(wxAcceleratorTable(_countof(entries), entries)); } @@ -141,6 +143,22 @@ void wxZRColaFrame::OnSend(wxCommandEvent& event) } +void wxZRColaFrame::OnAbort(wxCommandEvent& event) +{ + if (m_hWndSource) { + // Return focus to the source window. + ::SetActiveWindow(m_hWndSource); + ::SetForegroundWindow(m_hWndSource); + m_hWndSource = NULL; + + // Select all input in composer to prepare for the overwrite next time. + m_composer.SelectAll(); + } + + event.Skip(); +} + + void wxZRColaFrame::OnAbout(wxCommandEvent& event) { wxMessageBox(wxString::Format(_("ZRCola v%s\nCopyright 2015-%s Amebis"), wxT(ZRCOLA_VERSION_STR), wxT(ZRCOLA_BUILD_YEAR_STR)), _("About ZRCola"), wxOK | wxICON_INFORMATION); diff --git a/ZRCola/zrcolaframe.h b/ZRCola/zrcolaframe.h index c4b63fb..4cc4697 100644 --- a/ZRCola/zrcolaframe.h +++ b/ZRCola/zrcolaframe.h @@ -38,6 +38,7 @@ class wxZRColaFrame : public wxAppBarFrame protected: enum { wxID_SEND, + wxID_ABORT, wxID_COMPOSER, }; @@ -50,6 +51,7 @@ protected: void OnCompose(wxCommandEvent& event); void OnSendUpdate(wxUpdateUIEvent& event); void OnSend(wxCommandEvent& event); + void OnAbort(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); wxDECLARE_EVENT_TABLE();