Clipboard events are forwarded to focused control now

(resolves #12)
This commit is contained in:
Simon Rozman 2016-04-08 12:35:38 +02:00
parent cd2c20fc06
commit 98eff47054
2 changed files with 28 additions and 3 deletions

View File

@ -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);

View File

@ -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);