MenuItemToggle* MenuItemToggle::create(MenuItem *item) { MenuItemToggle *ret = new (std::nothrow) MenuItemToggle(); ret->initWithItem(item); ret->autorelease(); return ret; }
MenuItemToggle * MenuItemToggle::create() { MenuItemToggle *ret = new MenuItemToggle(); ret->initWithItem(nullptr); ret->autorelease(); return ret; }
MenuItemToggle* MenuItemToggle::create(MenuItem *item) { MenuItemToggle *pRet = new MenuItemToggle(); pRet->initWithItem(item); pRet->autorelease(); return pRet; }
MenuItemToggle * MenuItemToggle::createWithCallback(const ccMenuCallback &callback, MenuItem* item, ...) { va_list args; va_start(args, item); MenuItemToggle *ret = new (std::nothrow) MenuItemToggle(); ret->initWithCallback(callback, item, args); ret->autorelease(); va_end(args); return ret; }
// XXX: deprecated MenuItemToggle * MenuItemToggle::createWithTarget(Ref* target, SEL_MenuHandler selector, MenuItem* item, ...) { va_list args; va_start(args, item); MenuItemToggle *ret = new (std::nothrow) MenuItemToggle(); ret->initWithTarget(target, selector, item, args); ret->autorelease(); va_end(args); return ret; }
// XXX: deprecated MenuItemToggle * MenuItemToggle::createWithTarget(Object* target, SEL_MenuHandler selector, MenuItem* item, ...) { va_list args; va_start(args, item); MenuItemToggle *pRet = new MenuItemToggle(); pRet->initWithTarget(target, selector, item, args); pRet->autorelease(); va_end(args); return pRet; }
MenuItemToggle * MenuItemToggle::createWithCallback(const ccMenuCallback &callback, const Vector<MenuItem*>& menuItems) { MenuItemToggle *ret = new (std::nothrow) MenuItemToggle(); ret->MenuItem::initWithCallback(callback); ret->autorelease(); #if CC_ENABLE_GC_FOR_NATIVE_OBJECTS auto sEngine = ScriptEngineManager::getInstance()->getScriptEngine(); if (sEngine) { for (const auto &item : menuItems) { if (item) { sEngine->retainScriptObject(ret, item); } } } #endif // CC_ENABLE_GC_FOR_NATIVE_OBJECTS ret->_subItems = menuItems; ret->_selectedIndex = UINT_MAX; ret->setSelectedIndex(0); return ret; }
// FIXME:: deprecated MenuItemToggle * MenuItemToggle::createWithTarget(Ref* target, SEL_MenuHandler selector, const Vector<MenuItem*>& menuItems) { MenuItemToggle *ret = new (std::nothrow) MenuItemToggle(); ret->MenuItem::initWithCallback(std::bind(selector, target, std::placeholders::_1)); ret->autorelease(); #if CC_ENABLE_GC_FOR_NATIVE_OBJECTS auto sEngine = ScriptEngineManager::getInstance()->getScriptEngine(); if (sEngine) { for (const auto &item : menuItems) { if (item) { sEngine->retainScriptObject(ret, item); } } } #endif // CC_ENABLE_GC_FOR_NATIVE_OBJECTS ret->_subItems = menuItems; ret->_selectedIndex = UINT_MAX; ret->setSelectedIndex(0); return ret; }