Fixed RemoveItem and added Clear to Menus

rope
Bernhard Bonigl 2012-04-15 16:15:06 +02:00
parent 1dfc41042a
commit a1670205d3
1 changed files with 23 additions and 3 deletions

View File

@ -140,15 +140,35 @@ public func GetItems()
*/
public func RemoveItem(object item)
{
for (var mitem in menu_items)
var length = GetLength(menu_items);
for(var i = 0; i < length; i++)
{
if (mitem = item)
mitem->RemoveObject();
if (menu_items[i])
{
menu_items[i]->RemoveObject();
break;
}
}
// close gap
menu_items = Concatenate(menu_items[0:i],menu_items[i+1:length-1]);
UpdateMenu();
return;
}
/** Removes all items from the menu. */
public func Clear()
{
for (var mitem in menu_items)
{
mitem->RemoveObject();
}
menu_items = [];
UpdateMenu();
return;
}
/* Callbacks from the menu items, to be forwarded to the commander. */
/** Called when an item has been selected (left mouse button). **/