Menu/toolbar event handling now tries the window with the focus first.
wxTextCtrl processes cut, copy, paste, undo, redo commands and UI updates automatically. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2069 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -654,7 +654,13 @@ void wxFrame::Command( int id )
|
||||
{
|
||||
bar->Check(id,!bar->Checked(id)) ;
|
||||
}
|
||||
GetEventHandler()->ProcessEvent(commandEvent);
|
||||
|
||||
// Process events starting with the window with the focus, if any.
|
||||
wxWindow* focusWin = wxFindFocusDescendant(this);
|
||||
|
||||
wxEvtHandler* evtHandler = focusWin ? focusWin->GetEventHandler() : GetEventHandler();
|
||||
|
||||
evtHandler->ProcessEvent(commandEvent);
|
||||
}
|
||||
|
||||
void wxFrame::SetStatusText(const wxString& text, int number)
|
||||
|
@@ -12,6 +12,7 @@
|
||||
#endif
|
||||
|
||||
#include "wx/toolbar.h"
|
||||
#include "wx/frame.h"
|
||||
|
||||
#include "glib.h"
|
||||
#include "gdk/gdk.h"
|
||||
@@ -168,6 +169,28 @@ bool wxToolBar::OnLeftClick( int toolIndex, bool toggleDown )
|
||||
event.SetInt( toolIndex );
|
||||
event.SetExtraLong((long) toggleDown);
|
||||
|
||||
// First try sending the command to a window that has the focus, within a frame that
|
||||
// also contains this toolbar.
|
||||
wxFrame* frame = (wxFrame*) NULL;
|
||||
wxWindow* win = this;
|
||||
wxWindow* focusWin = (wxWindow*) NULL;
|
||||
|
||||
while (win)
|
||||
{
|
||||
if (win->IsKindOf(CLASSINFO(wxFrame)))
|
||||
{
|
||||
frame = (wxFrame*) win;
|
||||
break;
|
||||
}
|
||||
else
|
||||
win = win->GetParent();
|
||||
}
|
||||
if (frame)
|
||||
focusWin = wxFindFocusDescendant(frame);
|
||||
|
||||
if (focusWin && focusWin->GetEventHandler()->ProcessEvent(event))
|
||||
return TRUE;
|
||||
|
||||
GetEventHandler()->ProcessEvent(event);
|
||||
|
||||
return TRUE;
|
||||
|
@@ -65,6 +65,18 @@ IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl,wxControl)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
|
||||
EVT_CHAR(wxTextCtrl::OnChar)
|
||||
|
||||
EVT_MENU(wxID_CUT, wxTextCtrl::OnCut)
|
||||
EVT_MENU(wxID_COPY, wxTextCtrl::OnCopy)
|
||||
EVT_MENU(wxID_PASTE, wxTextCtrl::OnPaste)
|
||||
EVT_MENU(wxID_UNDO, wxTextCtrl::OnUndo)
|
||||
EVT_MENU(wxID_REDO, wxTextCtrl::OnRedo)
|
||||
|
||||
EVT_UPDATE_UI(wxID_CUT, wxTextCtrl::OnUpdateCut)
|
||||
EVT_UPDATE_UI(wxID_COPY, wxTextCtrl::OnUpdateCopy)
|
||||
EVT_UPDATE_UI(wxID_PASTE, wxTextCtrl::OnUpdatePaste)
|
||||
EVT_UPDATE_UI(wxID_UNDO, wxTextCtrl::OnUpdateUndo)
|
||||
EVT_UPDATE_UI(wxID_REDO, wxTextCtrl::OnUpdateRedo)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
#ifndef NO_TEXT_WINDOW_STREAM
|
||||
@@ -931,3 +943,52 @@ void wxTextCtrl::ApplyWidgetStyle()
|
||||
}
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnCut(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
Cut();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnCopy(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
Copy();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnPaste(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
Paste();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUndo(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
Undo();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnRedo(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
Redo();
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdateCut(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanCut() );
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdateCopy(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanCopy() );
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdatePaste(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanPaste() );
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdateUndo(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanUndo() );
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( CanRedo() );
|
||||
}
|
||||
|
Reference in New Issue
Block a user