From 98eff47054d23cf64d81399e87d3d9de87cc93f5 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Fri, 8 Apr 2016 12:35:38 +0200 Subject: [PATCH] Clipboard events are forwarded to focused control now (resolves #12) --- ZRCola/zrcolafrm.cpp | 29 ++++++++++++++++++++++++++--- ZRCola/zrcolafrm.h | 2 ++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/ZRCola/zrcolafrm.cpp b/ZRCola/zrcolafrm.cpp index c629b7a..e449bd1 100644 --- a/ZRCola/zrcolafrm.cpp +++ b/ZRCola/zrcolafrm.cpp @@ -25,13 +25,16 @@ ////////////////////////////////////////////////////////////////////////// wxBEGIN_EVENT_TABLE(wxZRColaFrame, wxZRColaFrameBase) - EVT_UPDATE_UI_RANGE(wxID_SEND_COMPOSED, wxID_SEND_ABORT, wxZRColaFrame::OnSendUpdate) + EVT_UPDATE_UI_RANGE(wxID_CUT, wxID_CLEAR, wxZRColaFrame::OnForwardEventUpdate) + EVT_MENU_RANGE(wxID_CUT, wxID_CLEAR, wxZRColaFrame::OnForwardEvent) + EVT_UPDATE_UI_RANGE(wxID_SEND_COMPOSED, wxID_SEND_ABORT, wxZRColaFrame::OnSendUpdate) EVT_MENU(wxID_SEND_COMPOSED , wxZRColaFrame::OnSendComposed ) EVT_MENU(wxID_SEND_DECOMPOSED, wxZRColaFrame::OnSendDecomposed ) EVT_MENU(wxID_SEND_ABORT , wxZRColaFrame::OnSendAbort ) - EVT_MENU(wxID_EXIT , wxZRColaFrame::OnExit ) - EVT_MENU(wxID_ABOUT , wxZRColaFrame::OnAbout ) + + EVT_MENU(wxID_EXIT , wxZRColaFrame::OnExit ) + EVT_MENU(wxID_ABOUT, wxZRColaFrame::OnAbout) wxEND_EVENT_TABLE() @@ -67,6 +70,26 @@ wxZRColaFrame::~wxZRColaFrame() } +void wxZRColaFrame::OnForwardEventUpdate(wxUpdateUIEvent& event) +{ + wxControl *focusWnd = wxDynamicCast(FindFocus(), wxControl); + if (focusWnd) + focusWnd->GetEventHandler()->ProcessEvent(event); + else + event.Enable(false); +} + + +void wxZRColaFrame::OnForwardEvent(wxCommandEvent& event) +{ + wxControl *focusWnd = wxDynamicCast(FindFocus(), wxControl); + if (focusWnd) + focusWnd->GetEventHandler()->ProcessEvent(event); + else + event.Skip(); +} + + void wxZRColaFrame::OnSendUpdate(wxUpdateUIEvent& event) { event.Enable(m_hWndSource ? true : false); diff --git a/ZRCola/zrcolafrm.h b/ZRCola/zrcolafrm.h index 62bbd67..8365548 100644 --- a/ZRCola/zrcolafrm.h +++ b/ZRCola/zrcolafrm.h @@ -46,6 +46,8 @@ public: virtual ~wxZRColaFrame(); protected: + void OnForwardEventUpdate(wxUpdateUIEvent& event); + void OnForwardEvent(wxCommandEvent& event); void OnSendUpdate(wxUpdateUIEvent& event); void OnSendComposed(wxCommandEvent& event); void OnSendDecomposed(wxCommandEvent& event);