fix (with a test) for wxMenu::UpdateUI bug (the handler defined in the menu class was never used)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@8046 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-08-12 13:30:47 +00:00
parent f21cb9a888
commit d19729d528
2 changed files with 38 additions and 5 deletions

View File

@@ -77,6 +77,7 @@ public:
void OnRightDown(wxMouseEvent& event);
void OnUpdateCheckMenuItemUI(wxUpdateUIEvent& event);
void OnUpdatePopup(wxUpdateUIEvent& event) { event.Enable(FALSE); }
private:
wxMenu *CreateDummyMenu(wxString *title);
@@ -109,6 +110,17 @@ private:
DECLARE_EVENT_TABLE()
};
class MyPopupMenu : public wxMenu
{
public:
MyPopupMenu(const wxString& title) : wxMenu(title) { }
void OnUpdateUI(wxUpdateUIEvent& event) { event.Enable(FALSE); }
private:
DECLARE_EVENT_TABLE()
};
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
@@ -145,6 +157,8 @@ enum
Menu_Popup_ToBeDeleted = 2000,
Menu_Popup_ToBeGreyed,
Menu_Popup_ToBeGreyed2,
Menu_Popup_ToBeGreyed3,
Menu_Popup_ToBeChecked,
Menu_Popup_Submenu,
@@ -182,6 +196,8 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_UPDATE_UI(Menu_Menu_Check, MyFrame::OnUpdateCheckMenuItemUI)
EVT_UPDATE_UI(Menu_Popup_ToBeGreyed3, MyFrame::OnUpdatePopup)
EVT_RIGHT_DOWN(MyFrame::OnRightDown)
END_EVENT_TABLE()
@@ -189,6 +205,10 @@ BEGIN_EVENT_TABLE(MyEvtHandler, wxEvtHandler)
EVT_MENU(-1, MyEvtHandler::OnMenuEvent)
END_EVENT_TABLE()
BEGIN_EVENT_TABLE(MyPopupMenu, wxMenu)
EVT_UPDATE_UI(Menu_Popup_ToBeGreyed2, MyPopupMenu::OnUpdateUI)
END_EVENT_TABLE()
// ============================================================================
// implementation
// ============================================================================
@@ -618,7 +638,7 @@ void MyFrame::OnGetMenuItemInfo(wxCommandEvent& WXUNUSED(event))
void MyFrame::OnRightDown(wxMouseEvent &event )
{
wxMenu menu("Test popup");
MyPopupMenu menu("Test popup");
menu.Append(Menu_Help_About, "&About");
menu.Append(Menu_Popup_Submenu, "Submenu", CreateDummyMenu(NULL));
@@ -626,6 +646,10 @@ void MyFrame::OnRightDown(wxMouseEvent &event )
menu.Append(Menu_Popup_ToBeChecked, "To be checked", "", TRUE);
menu.Append(Menu_Popup_ToBeGreyed, "To be greyed");
menu.AppendSeparator();
// VZ: don't search for the word autogreyed in the dictionary...
menu.Append(Menu_Popup_ToBeGreyed2, "To be autogreyed");
menu.Append(Menu_Popup_ToBeGreyed3, "This one too");
menu.AppendSeparator();
menu.Append(Menu_File_Quit, "E&xit");
menu.Delete(Menu_Popup_ToBeDeleted);