Game Development Community

T3D 1.1 Final - Minus symbol (-) in guiMenuBar item name - LOGGED (THREED-2125)

by Nathan Bowhay - ESAL · in Torque 3D Professional · 07/05/2011 (3:56 pm) · 3 replies

Build: 1.1 Final
Platform: Windows Vista
Target: guiMenuBar
Issues: If you use a "-" or minus as the first character in a menu bar item/subitem, no matter how long the text is it will auto disable it. Not sure if is this is the only behavior caused by this. An example would be "-X Axis".

Steps to Repeat:
1. Create a guiMenuBar in the gui editor and name it "myMenuBar".
2. Add the code:
myMenuBar.addMenuItem("Edit", "Align Bounds", 8);
myMenuBar.setMenuItemSubmenuState("Edit", "Align Bounds", true);
myMenuBar.addSubmenuItem("Edit", "Align Bounds", "+X Axis", 1);

Suggested Fix: In guiMenuBar.cpp on line 1380 or so change the code from:
newMenuItem->enabled = text[0] != '-';
to
newMenuItem->enabled = (dStrlen(text) > 1 || text[0] != '-');

#1
07/06/2011 (1:24 pm)
Thanks Nathan. Logged as THREED-2125.
#2
07/06/2011 (2:00 pm)
I just reviewed the code and what is going on is addMenuItem() and addSubmenuItem() methods of GuiMenuBar are emulating the classic MFC menu item separator whenever a user uses just a hyphen/negative symbol to indicate that item is suppose to just be a item separator. And separators are obviously suppose to be in a disabled/inactive state.

Could use this alternative to make it more clear as to what the intentional conditions are:
newMenuItem->enabled = (dStrlen(text) == 1 && text[0] == '-')? false:true;
#3
11/16/2011 (2:49 pm)
I have just confirmed that this bug is still present in T3D 1.2.