Page 1 of 1

Disabled context menu items still spawn submenu

Posted: Tue Dec 02, 2008 6:49 pm
by drewbacca
If you disable a menu item, its submenu still appears when you mouse over the disabled item. I tested this with Irrlicht svn r1900 using the 1.5 branch.

You can create the bug by editing the example meshviewer to disable one of the menu items with a submenu.

Image

Code: Select all

Index: main.cpp
===================================================================
--- main.cpp	(revision 1900)
+++ main.cpp	(working copy)
@@ -646,6 +646,7 @@
 	submenu->addItem(L"sky box visible", 300, true, false, true);
 	submenu->addItem(L"toggle model debug information", 400, true, true);
 	submenu->addItem(L"model material", -1, true, true );
+	submenu->setItemEnabled(2, false);
 
 	submenu = submenu->getSubMenu(1);
 	submenu->addItem(L"Off", 401);

I am not sure if my fix is the best or most efficient, but I just added a check to see if menu items are disabled before expanding the submenu, and it seemed to correct the problem.

Here is my fix:

Code: Select all

Index: CGUIContextMenu.cpp
===================================================================
--- CGUIContextMenu.cpp	(revision 1900)
+++ CGUIContextMenu.cpp	(working copy)
@@ -378,7 +378,7 @@
 				for (s32 j=0; j<(s32)Items.size(); ++j)
 					if (Items[j].SubMenu)
 					{
-						if ( j == i && canOpenSubMenu )
+						if ( j == i && canOpenSubMenu && Items[j].Enabled)
 							Items[j].SubMenu->setVisible(true);
 						else if ( j != i )
 							Items[j].SubMenu->setVisible(false);

Posted: Tue Dec 02, 2008 8:57 pm
by rogerborg
Great, thanks for the report and the fix. Added in SVN 1906.