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:
@@ -24,6 +24,8 @@
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include "wx/frame.h"
|
||||
|
||||
// For ::UpdateWindow
|
||||
#ifdef __WXMSW__
|
||||
#include <windows.h>
|
||||
@@ -147,6 +149,29 @@ bool wxToolBarBase::OnLeftClick(int toolIndex, bool toggleDown)
|
||||
event.SetEventObject(this);
|
||||
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;
|
||||
|
||||
// Send events to this toolbar instead (and thence up the window hierarchy)
|
||||
GetEventHandler()->ProcessEvent(event);
|
||||
|
||||
return TRUE;
|
||||
@@ -732,6 +757,28 @@ void wxToolBarBase::OnIdle(wxIdleEvent& event)
|
||||
// Do the toolbar button updates (check for EVT_UPDATE_UI handlers)
|
||||
void wxToolBarBase::DoToolbarUpdates()
|
||||
{
|
||||
// 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);
|
||||
|
||||
|
||||
wxEvtHandler* evtHandler = focusWin ? focusWin->GetEventHandler() : GetEventHandler() ;
|
||||
|
||||
wxNode* node = GetTools().First();
|
||||
while (node)
|
||||
{
|
||||
@@ -740,7 +787,7 @@ void wxToolBarBase::DoToolbarUpdates()
|
||||
wxUpdateUIEvent event(tool->m_index);
|
||||
event.SetEventObject(this);
|
||||
|
||||
if (GetEventHandler()->ProcessEvent(event))
|
||||
if (evtHandler->ProcessEvent(event))
|
||||
{
|
||||
if (event.GetSetEnabled())
|
||||
EnableTool(tool->m_index, event.GetEnabled());
|
||||
|
Reference in New Issue
Block a user