mirror of https://github.com/axmolengine/axmol.git
Added Method to create a CCMenuItemToggle from a CCArray with a target selector.
This commit is contained in:
parent
2be1347dc7
commit
94a5cdad29
|
@ -714,6 +714,24 @@ CCArray* CCMenuItemToggle::getSubItems()
|
||||||
return m_pSubItems;
|
return m_pSubItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CCMenuItemToggle * CCMenuItemToggle::createWithTarget(CCObject* target, SEL_MenuHandler selector, CCArray* menuItems)
|
||||||
|
{
|
||||||
|
CCMenuItemToggle *pRet = new CCMenuItemToggle();
|
||||||
|
pRet->CCMenuItem::initWithTarget(target, selector);
|
||||||
|
pRet->m_pSubItems = CCArray::create();
|
||||||
|
pRet->m_pSubItems->retain();
|
||||||
|
|
||||||
|
for (int z=0; z < menuItems->count(); z++)
|
||||||
|
{
|
||||||
|
CCMenuItem* menuItem = (CCMenuItem*)menuItems->objectAtIndex(z);
|
||||||
|
pRet->m_pSubItems->addObject(menuItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
pRet->m_uSelectedIndex = UINT_MAX;
|
||||||
|
pRet->setSelectedIndex(0);
|
||||||
|
return pRet;
|
||||||
|
}
|
||||||
|
|
||||||
CCMenuItemToggle * CCMenuItemToggle::createWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...)
|
CCMenuItemToggle * CCMenuItemToggle::createWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
|
@ -322,6 +322,9 @@ public:
|
||||||
, m_pSubItems(NULL)
|
, m_pSubItems(NULL)
|
||||||
{}
|
{}
|
||||||
virtual ~CCMenuItemToggle();
|
virtual ~CCMenuItemToggle();
|
||||||
|
|
||||||
|
** creates a menu item from a CCArray with a target selector */
|
||||||
|
static CCMenuItemToggle * createWithTarget(CCObject* target, SEL_MenuHandler selector, CCArray* menuItems);
|
||||||
|
|
||||||
/** creates a menu item from a list of items with a target/selector */
|
/** creates a menu item from a list of items with a target/selector */
|
||||||
static CCMenuItemToggle* createWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...);
|
static CCMenuItemToggle* createWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...);
|
||||||
|
|
Loading…
Reference in New Issue