mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-03 20:40:35 +00:00
Merge pull request #2250 from Areloch/popupMenuFixesPR
Fixes various incorrect popup menu behaviors.
This commit is contained in:
commit
d2a78b0a82
11 changed files with 305 additions and 498 deletions
|
|
@ -205,7 +205,7 @@ bool PopupMenu::setItem(S32 pos, const char *title, const char* accelerator, con
|
|||
|
||||
void PopupMenu::removeItem(S32 itemPos)
|
||||
{
|
||||
if (mMenuItems.size() < itemPos || itemPos < 0)
|
||||
if (mMenuItems.empty() || mMenuItems.size() < itemPos || itemPos < 0)
|
||||
return;
|
||||
|
||||
mMenuItems.erase(itemPos);
|
||||
|
|
@ -214,7 +214,7 @@ void PopupMenu::removeItem(S32 itemPos)
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
void PopupMenu::enableItem(S32 pos, bool enable)
|
||||
{
|
||||
if (mMenuItems.size() < pos || pos < 0)
|
||||
if (mMenuItems.empty() || mMenuItems.size() < pos || pos < 0)
|
||||
return;
|
||||
|
||||
mMenuItems[pos].mEnabled = enable;
|
||||
|
|
@ -222,7 +222,7 @@ void PopupMenu::enableItem(S32 pos, bool enable)
|
|||
|
||||
void PopupMenu::checkItem(S32 pos, bool checked)
|
||||
{
|
||||
if (mMenuItems.size() < pos || pos < 0)
|
||||
if (mMenuItems.empty() || mMenuItems.size() < pos || pos < 0)
|
||||
return;
|
||||
|
||||
if (checked && mMenuItems[pos].mCheckGroup != -1)
|
||||
|
|
@ -249,7 +249,7 @@ void PopupMenu::checkRadioItem(S32 firstPos, S32 lastPos, S32 checkPos)
|
|||
|
||||
bool PopupMenu::isItemChecked(S32 pos)
|
||||
{
|
||||
if (mMenuItems.size() < pos || pos < 0)
|
||||
if (mMenuItems.empty() || mMenuItems.size() < pos || pos < 0)
|
||||
return false;
|
||||
|
||||
return mMenuItems[pos].mIsChecked;
|
||||
|
|
@ -260,6 +260,11 @@ U32 PopupMenu::getItemCount()
|
|||
return mMenuItems.size();
|
||||
}
|
||||
|
||||
void PopupMenu::clearItems()
|
||||
{
|
||||
mMenuItems.clear();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool PopupMenu::canHandleID(U32 id)
|
||||
{
|
||||
|
|
@ -504,6 +509,11 @@ DefineConsoleMethod(PopupMenu, getItemCount, S32, (), , "()")
|
|||
return object->getItemCount();
|
||||
}
|
||||
|
||||
DefineConsoleMethod(PopupMenu, clearItems, void, (), , "()")
|
||||
{
|
||||
return object->clearItems();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
DefineConsoleMethod(PopupMenu, showPopup, void, (const char * canvasName, S32 x, S32 y), ( -1, -1), "(Canvas,[x, y])")
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue