Return correct menu pointer for wxEVT_MENU_{OPEN,CLOSE} in MDI frames.
These events are supposed to carry a pointer to the menu which was opened or closed, but wxMenuEvent::GetMenu() always returned NULL for the menus opened when a child MDI frame was active, as its menu bar, containing the menu, was not searched for it. Fix this by overriding MSWFindMenuFromHMENU() at wxMDIParentFrame level, just as we already do for FindItemInMenuBar(). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78130 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -70,6 +70,9 @@ wxBEGIN_EVENT_TABLE(MyFrame, wxMDIParentFrame)
|
||||
|
||||
EVT_MENU(wxID_CLOSE_ALL, MyFrame::OnCloseAll)
|
||||
|
||||
EVT_MENU_OPEN(MyFrame::OnMenuOpen)
|
||||
EVT_MENU_CLOSE(MyFrame::OnMenuClose)
|
||||
|
||||
EVT_CLOSE(MyFrame::OnClose)
|
||||
wxEND_EVENT_TABLE()
|
||||
|
||||
@@ -91,6 +94,9 @@ wxBEGIN_EVENT_TABLE(MyChild, wxMDIChildFrame)
|
||||
EVT_SIZE(MyChild::OnSize)
|
||||
EVT_MOVE(MyChild::OnMove)
|
||||
|
||||
EVT_MENU_OPEN(MyChild::OnMenuOpen)
|
||||
EVT_MENU_CLOSE(MyChild::OnMenuClose)
|
||||
|
||||
EVT_CLOSE(MyChild::OnCloseWindow)
|
||||
wxEND_EVENT_TABLE()
|
||||
|
||||
@@ -132,7 +138,8 @@ bool MyApp::OnInit()
|
||||
// Define my frame constructor
|
||||
MyFrame::MyFrame()
|
||||
: wxMDIParentFrame(NULL, wxID_ANY, "wxWidgets MDI Sample",
|
||||
wxDefaultPosition, wxSize(500, 400))
|
||||
wxDefaultPosition, wxSize(500, 400)),
|
||||
MenuEventLogger("parent", this)
|
||||
{
|
||||
SetIcon(wxICON(sample));
|
||||
|
||||
@@ -175,9 +182,13 @@ MyFrame::MyFrame()
|
||||
#endif // wxUSE_STATUSBAR
|
||||
|
||||
|
||||
m_textWindow = new wxTextCtrl(this, wxID_ANY, "A help window",
|
||||
m_textWindow = new wxTextCtrl(this, wxID_ANY, "A log window\n",
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxTE_MULTILINE | wxSUNKEN_BORDER);
|
||||
wxTE_MULTILINE | wxTE_READONLY);
|
||||
|
||||
// don't clutter the text window with time stamps
|
||||
wxLog::DisableTimestamp();
|
||||
delete wxLog::SetActiveTarget(new wxLogTextCtrl(m_textWindow));
|
||||
|
||||
#if wxUSE_TOOLBAR
|
||||
CreateToolBar(wxNO_BORDER | wxTB_FLAT | wxTB_HORIZONTAL);
|
||||
@@ -203,6 +214,9 @@ MyFrame::~MyFrame()
|
||||
// and disconnect it to prevent accessing already deleted m_textWindow in
|
||||
// the size event handler if it's called during destruction
|
||||
Disconnect(wxEVT_SIZE, wxSizeEventHandler(MyFrame::OnSize));
|
||||
|
||||
// also prevent its use as log target
|
||||
delete wxLog::SetActiveTarget(NULL);
|
||||
}
|
||||
|
||||
#if wxUSE_MENUS
|
||||
@@ -414,7 +428,8 @@ MyChild::MyChild(wxMDIParentFrame *parent)
|
||||
parent,
|
||||
wxID_ANY,
|
||||
wxString::Format("Child %u", ++ms_numChildren)
|
||||
)
|
||||
),
|
||||
MenuEventLogger("child", this)
|
||||
{
|
||||
m_canvas = new MyCanvas(this, wxPoint(0, 0), GetClientSize());
|
||||
|
||||
|
Reference in New Issue
Block a user