context sub menu question

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
juliusctw
Posts: 392
Joined: Fri Apr 21, 2006 6:56 am
Contact:

context sub menu question

Post 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 ????? :?
HighBuddha
Posts: 11
Joined: Thu Jun 15, 2006 12:46 am

Post 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
Post Reply