Abort added

This commit is contained in:
Simon Rozman 2016-02-07 11:08:26 +01:00
parent e6104534d8
commit 2c58dd68ba
2 changed files with 21 additions and 1 deletions

View File

@ -28,6 +28,7 @@ wxBEGIN_EVENT_TABLE(wxZRColaFrame, wxAppBarFrame)
EVT_TEXT (wxZRColaFrame::wxID_COMPOSER, wxZRColaFrame::OnCompose ) EVT_TEXT (wxZRColaFrame::wxID_COMPOSER, wxZRColaFrame::OnCompose )
EVT_UPDATE_UI(wxZRColaFrame::wxID_SEND , wxZRColaFrame::OnSendUpdate) EVT_UPDATE_UI(wxZRColaFrame::wxID_SEND , wxZRColaFrame::OnSendUpdate)
EVT_MENU (wxZRColaFrame::wxID_SEND , wxZRColaFrame::OnSend ) EVT_MENU (wxZRColaFrame::wxID_SEND , wxZRColaFrame::OnSend )
EVT_MENU (wxZRColaFrame::wxID_ABORT , wxZRColaFrame::OnAbort )
EVT_MENU ( wxID_ABOUT , wxZRColaFrame::OnAbout ) EVT_MENU ( wxID_ABOUT , wxZRColaFrame::OnAbout )
wxEND_EVENT_TABLE() wxEND_EVENT_TABLE()
@ -76,8 +77,9 @@ bool wxZRColaFrame::Create()
// Register frame specific hotkey(s). // Register frame specific hotkey(s).
{ {
wxAcceleratorEntry entries[1]; wxAcceleratorEntry entries[2];
entries[0].Set(wxACCEL_NORMAL, WXK_RETURN, wxID_SEND); entries[0].Set(wxACCEL_NORMAL, WXK_RETURN, wxID_SEND);
entries[1].Set(wxACCEL_NORMAL, WXK_ESCAPE, wxID_ABORT);
SetAcceleratorTable(wxAcceleratorTable(_countof(entries), entries)); 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) 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); wxMessageBox(wxString::Format(_("ZRCola v%s\nCopyright 2015-%s Amebis"), wxT(ZRCOLA_VERSION_STR), wxT(ZRCOLA_BUILD_YEAR_STR)), _("About ZRCola"), wxOK | wxICON_INFORMATION);

View File

@ -38,6 +38,7 @@ class wxZRColaFrame : public wxAppBarFrame
protected: protected:
enum { enum {
wxID_SEND, wxID_SEND,
wxID_ABORT,
wxID_COMPOSER, wxID_COMPOSER,
}; };
@ -50,6 +51,7 @@ protected:
void OnCompose(wxCommandEvent& event); void OnCompose(wxCommandEvent& event);
void OnSendUpdate(wxUpdateUIEvent& event); void OnSendUpdate(wxUpdateUIEvent& event);
void OnSend(wxCommandEvent& event); void OnSend(wxCommandEvent& event);
void OnAbort(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event); void OnAbout(wxCommandEvent& event);
wxDECLARE_EVENT_TABLE(); wxDECLARE_EVENT_TABLE();