Page 1 of 1

GUI Elements - Setting a submenu

Posted: Wed Feb 18, 2004 2:06 pm
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?

Posted: Wed Feb 18, 2004 3:38 pm
by niko
Just do a IGUIContextMenu::getSubMenu() with the index you received.

Posted: Wed Feb 18, 2004 3:47 pm
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

Posted: Sun Feb 29, 2004 11:05 pm
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 :(

Posted: Mon Mar 01, 2004 10:53 am
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

Posted: Mon Mar 01, 2004 11:42 am
by niko
You could try and use

Code: Select all

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