Code: Select all
void MenuItem::closeAllMenuItemPopups()
{
// are we attached to a PopupMenu?
PopupMenu* pop = (PopupMenu*)getParent();
if (getParent()->testClassName("PopupMenu") && pop->isItemInList(this))
{
// is this parent popup attached to a menu item?
MenuItem* item = (MenuItem*)pop->getParent();
if (item!=NULL && item->testClassName("MenuItem"))
{
// close popup
item->closePopupMenu();
// recurse
item->closeAllMenuItemPopups();
}
// otherwise we just hide ourselves
else
{
//----------------------------------
//ATTENTION HERE!!!!
//If "item" is NOT a MenuItem class, this line will crash the application
//----------------------------------
item->closePopupMenu();
}
}
}