Test code for removing a submenu
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@20122 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -68,9 +68,13 @@ check the source for this sample to see how to implement them.
|
|||||||
|
|
||||||
menu5 = wxMenu()
|
menu5 = wxMenu()
|
||||||
menu5.Append(501, "Interesting thing\tCtrl+A", "Note the shortcut!")
|
menu5.Append(501, "Interesting thing\tCtrl+A", "Note the shortcut!")
|
||||||
|
|
||||||
menu5.AppendSeparator()
|
menu5.AppendSeparator()
|
||||||
menu5.Append(502, "Hello\tShift+H")
|
menu5.Append(502, "Hello\tShift+H")
|
||||||
|
menu5.AppendSeparator()
|
||||||
|
menu5.Append(503, "remove the submenu")
|
||||||
|
menu6 = wxMenu()
|
||||||
|
menu6.Append(601, "Submenu Item")
|
||||||
|
menu5.AppendMenu(504, "submenu", menu6)
|
||||||
menuBar.Append(menu5, "&Fun")
|
menuBar.Append(menu5, "&Fun")
|
||||||
|
|
||||||
self.SetMenuBar(menuBar)
|
self.SetMenuBar(menuBar)
|
||||||
@@ -97,6 +101,7 @@ check the source for this sample to see how to implement them.
|
|||||||
|
|
||||||
EVT_MENU(self, 501, self.Menu501)
|
EVT_MENU(self, 501, self.Menu501)
|
||||||
EVT_MENU(self, 502, self.Menu502)
|
EVT_MENU(self, 502, self.Menu502)
|
||||||
|
EVT_MENU(self, 503, self.TestRemove)
|
||||||
|
|
||||||
# Methods
|
# Methods
|
||||||
|
|
||||||
@@ -146,6 +151,20 @@ check the source for this sample to see how to implement them.
|
|||||||
def Menu502(self, event):
|
def Menu502(self, event):
|
||||||
self.log.write('Hello from Jean-Michel\n')
|
self.log.write('Hello from Jean-Michel\n')
|
||||||
|
|
||||||
|
|
||||||
|
def TestRemove(self, evt):
|
||||||
|
mb = self.GetMenuBar()
|
||||||
|
submenuItem = mb.FindItemById(601)
|
||||||
|
if not submenuItem:
|
||||||
|
return
|
||||||
|
submenu = submenuItem.GetMenu()
|
||||||
|
menu = submenu.GetParent()
|
||||||
|
|
||||||
|
#menu.Remove(504) # works
|
||||||
|
menu.RemoveItem(mb.FindItemById(504)) # this also works
|
||||||
|
#menu.RemoveItem(submenuItem) # doesn't work, as expected since submenuItem is not on menu
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
def runTest(frame, nb, log):
|
def runTest(frame, nb, log):
|
||||||
|
Reference in New Issue
Block a user