Disabled context menu items still spawn submenu

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
drewbacca
Posts: 38
Joined: Tue Jan 30, 2007 6:49 pm

Disabled context menu items still spawn submenu

Post 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);
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Great, thanks for the report and the fix. Added in SVN 1906.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply