Page 1 of 1

context sub menu question

Posted: Mon Jul 24, 2006 3:23 pm
by juliusctw
Hello

reading from the API for contextMenu, it doesn't seem to have a function that adds items to the sub menu, you can add an ITem with sub menu, but no way to add it, am i missing something ????? :?

Posted: Mon Jul 24, 2006 9:13 pm
by HighBuddha
I am not entirely clear on what you are asking? Do you mean it doesn't have a function called addItem? or you don't know how to add an item? either way here is how to add a submenu to a context menu.

first you create 2 context menus:

gui::IGUIContextMenu* menu;
gui::IGUIContextMenu* submenu;

one will be the main menu the other the submenu(s).

menu = env->addMenu(); // this will create the main menu
menu->addItem(L"name", id); //here you add your main items. The id is
used in the event handeler.

submenu = menu->getSubMenu(0); //this will add a submenu to an item in menu. the number indicates which menu to add the submenu to. 1 would be the first menu item, 2 the second, and so on in that fashion.

Then you simpley add the necessary code into the event handeler to do something with these menus and thats it :D

hope that helps :P