hello
I create a menu with many submenus (with the same ID) in a for loop (menu is created dyamicaly)
but in the event, how do I differentiate them as the event occur?
I tried GetString() but it returns an empty string
GetInt() returns always 1
thanks
dynamic submenu id?
-
- In need of some credit
- Posts: 8
- Joined: Thu Aug 28, 2014 12:24 pm
Re: dynamic submenu id?
You shouldn't use the same id for multiple menu items. Use wxID_ANY, this should assign a new id internally. Then in the event handler you can get the current menu item using event.GetId() and wxMenuBar::FindItem().
Use the source, Luke!
-
- In need of some credit
- Posts: 8
- Joined: Thu Aug 28, 2014 12:24 pm
Re: dynamic submenu id?
ok thxdoublemax wrote:You shouldn't use the same id for multiple menu items. Use wxID_ANY, this should assign a new id internally. Then in the event handler you can get the current menu item using event.GetId() and wxMenuBar::FindItem().
but using wxID_ANY then how do I know witch ID is assigned to witch menu ?
Re: dynamic submenu id?
With the methods i mentioned above you can access the menu item which gives you the text of the menu. If that's not enough, the best solution depends on your actual task, what kind of information you need to transport to the event handler.
The most generic way would be to derive your own class from wxMenuItem and use wxMenu::Append( wxMenuItem *menuItem) to add it to the menu. That way you can transport any information you like inside the menu item.
The most generic way would be to derive your own class from wxMenuItem and use wxMenu::Append( wxMenuItem *menuItem) to add it to the menu. That way you can transport any information you like inside the menu item.
Use the source, Luke!