GUI Elements - Setting a submenu

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
saigumi
Posts: 921
Joined: Fri Aug 22, 2003 11:31 am
Location: St. Louis, MO USA
Contact:

GUI Elements - Setting a submenu

Post by saigumi »

How do you set a submenu to a menu item.

I set the hasSubMenu flag to true, but MenuItem returns an index to the item, not a pointer to the element.

So, how do I attach a IGUIContextMenu to the MenuItem?
Crud, how do I do this again?
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

Just do a IGUIContextMenu::getSubMenu() with the index you received.
saigumi
Posts: 921
Joined: Fri Aug 22, 2003 11:31 am
Location: St. Louis, MO USA
Contact:

Post by saigumi »

Oh.. that returns the pointer, then you would call addItem or addSeperator to that pointer, instead of making your own ContextMenu pointer and assigning it to the menu item.

Makes sense
Crud, how do I do this again?
Mercior
Posts: 100
Joined: Tue Feb 24, 2004 1:53 am
Location: UK
Contact:

Post by Mercior »

How exactly is this supposed to work? Im using this code:

Code: Select all

	
mainmenu = world->guienv->addMenu();
s32 m1 = mainmenu->addItem(L"New");
s32 m2 = mainmenu->addItem(L"Load");

if (!mainmenu->getSubMenu(m1))
{
	printf("Failed to load submenu\n");
	return;
}

IGUIContextMenu *tmp = mainmenu->getSubMenu(m1);
tmp->addItem(L"omgz0r");
getSubMenu is always returning 0 :(
Mercior
Posts: 100
Joined: Tue Feb 24, 2004 1:53 am
Location: UK
Contact:

Post by Mercior »

Nevermind, I found that I needed to set the hasSubMenu flag :)

Another question though - how do you add menu items using a char array for the text? I tried addItem((wchar_t*)text) but it always comes out blank
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

You could try and use

Code: Select all

core::stringw text = yourCharText;
addItem(text.c_str());
Post Reply