mirror of https://github.com/axmolengine/axmol.git
30 lines
1.2 KiB
C++
30 lines
1.2 KiB
C++
#include "CCMenuItemLoader.h"
|
|
|
|
|
|
|
|
#define PROPERTY_BLOCK "block"
|
|
#define PROPERTY_ISENABLED "isEnabled"
|
|
|
|
NS_CC_EXT_BEGIN
|
|
|
|
void CCMenuItemLoader::onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, const char * pPropertyName, BlockData * pBlockData, CCBReader * pCCBReader) {
|
|
if(strcmp(pPropertyName, PROPERTY_BLOCK) == 0) {
|
|
if (NULL != pBlockData) // Add this condition to allow CCMenuItemImage without target/selector predefined
|
|
{
|
|
((CCMenuItem *)pNode)->setCallback( std::bind( pBlockData->mSELMenuHandler, pBlockData->mTarget, std::placeholders::_1) );
|
|
// ((CCMenuItem *)pNode)->setTarget(pBlockData->mTarget, pBlockData->mSELMenuHandler);
|
|
}
|
|
} else {
|
|
CCNodeLoader::onHandlePropTypeBlock(pNode, pParent, pPropertyName, pBlockData, pCCBReader);
|
|
}
|
|
}
|
|
|
|
void CCMenuItemLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader) {
|
|
if(strcmp(pPropertyName, PROPERTY_ISENABLED) == 0) {
|
|
((CCMenuItem *)pNode)->setEnabled(pCheck);
|
|
} else {
|
|
CCNodeLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, pCCBReader);
|
|
}
|
|
}
|
|
|
|
NS_CC_EXT_END |