void CCBProxy::setCallback(CCNode* pNode,int nHandle,int nControlEvents) { if (NULL == pNode) { return; } if (NULL != dynamic_cast<CCMenuItem*>(pNode)) { CCMenuItem *pMenuItem = dynamic_cast<CCMenuItem*>(pNode); if (NULL != pMenuItem) { pMenuItem->registerScriptTapHandler(nHandle); } } else if (NULL != dynamic_cast<CCControl*>(pNode)) { CCControl* pControl = dynamic_cast<CCControl*>(pNode); if (NULL != pControl) { for (int i = 0; i < kControlEventTotalNumber; i++) { if ((nControlEvents & (1 << i))) { pControl->addHandleOfControlEvent(nHandle, 1 << i); } } } } }
void HTouchEnabledLayerColor::setPriority(CCNode *node, int priority) { if (dynamic_cast<CCControl *>(node)) { CCControl *control = (CCControl *)node; control->setTouchPriority(priority); if (control->isTouchEnabled()) { control->setTouchEnabled(false); control->setTouchEnabled(true); } } else if (dynamic_cast<CCScrollView *>(node)) { CCScrollView *scrollView = (CCScrollView *)node; scrollView->setTouchPriority(priority); if (scrollView->isTouchEnabled()) { scrollView->setTouchEnabled(false); scrollView->setTouchEnabled(true); } } else if (dynamic_cast<CCMenu *>(node)) { CCMenu *menu = (CCMenu *)node; menu->setTouchPriority(priority); if (menu->isTouchEnabled()) { menu->setTouchEnabled(false); menu->setTouchEnabled(true); } } else if (dynamic_cast<CCLayer *>(node)) { CCLayer *layer = (CCLayer *)node; layer->setTouchPriority(priority); if (layer->isTouchEnabled()) { layer->setTouchEnabled(false); layer->setTouchEnabled(true); } } }
CCControl* CCControl::create() { CCControl* pRet = new CCControl(); if (pRet && pRet->init()) { pRet->autorelease(); return pRet; } else { CC_SAFE_DELETE(pRet); return NULL; } }
CCControl* CCControl::create() { CCControl* pRet = new CCControl(); if (pRet && pRet->init()) { //DuongNT: assign v8 obj here pRet->assignJavaScriptObject(CLS_CCCONTROL_ID, false); pRet->autorelease(); return pRet; } else { CC_SAFE_DELETE(pRet); return NULL; } }
CCObject *HTouchEnabledLayerColor::updatePriorityEx(int command, CCNode *node) { int iBasePriority = getTouchPriority(); if (dynamic_cast<CCControl *>(node)) { CCControl *control = (CCControl *)node; int priority = control->getTouchPriority(); priority = iBasePriority - 9; control->setTouchPriority(priority); if (control->isTouchEnabled()) { control->setTouchEnabled(false); control->setTouchEnabled(true); } } else if (dynamic_cast<CCScrollView *>(node)) { CCScrollView *scrollView = (CCScrollView *)node; int priority = scrollView->getTouchPriority(); priority = iBasePriority - 11; scrollView->setTouchPriority(priority); if (scrollView->isTouchEnabled()) { scrollView->setTouchEnabled(false); scrollView->setTouchEnabled(true); } } else if (dynamic_cast<CCMenu *>(node)) { CCMenu *menu = (CCMenu *)node; int priority = menu->getTouchPriority(); priority = iBasePriority - 128; menu->setTouchPriority(priority); if (menu->isTouchEnabled()) { menu->setTouchEnabled(false); menu->setTouchEnabled(true); } } else if (dynamic_cast<CCLayer *>(node)) { CCLayer *layer = (CCLayer *)node; int priority = layer->getTouchPriority(); priority = iBasePriority; layer->setTouchPriority(priority); if (layer->isTouchEnabled()) { layer->setTouchEnabled(false); layer->setTouchEnabled(true); } } CCArray *children = node->getChildren(); if (children) { int count = children->count(); for (int i = 0; i < count; ++i) { CCNode *child = (CCNode *)children->objectAtIndex(i); updatePriorityEx(command, child); } } return NULL; }