void PhotoSelectSence::selectedPhotoEvent(Ref *pSender, ListViewEventType type) { switch (type) { case LISTVIEW_ONSELECTEDITEM_START: { ListView* listView = static_cast<ListView*>(pSender); CC_UNUSED_PARAM(listView); CCLOG("select child start index = %ld", listView->getCurSelectedIndex()); _selectPhotoStarted = true; _selectPhotoStartIndex = listView->getCurSelectedIndex(); break; } case LISTVIEW_ONSELECTEDITEM_END: { ListView* listView = static_cast<ListView*>(pSender); CC_UNUSED_PARAM(listView); CCLOG("select child end index = %ld", listView->getCurSelectedIndex()); // 点击起始的Index和点击结束的Index一致才能为有效选择 if (_selectPhotoStartIndex == listView->getCurSelectedIndex()) { // 先原来的照片停止闪 ((ImageViewWithSelectBox*)listView->getItem(_selectedPhotoIndex))->stopBlink(); // 再选中的照片开始闪 ((ImageViewWithSelectBox*)listView->getItem(_selectPhotoStartIndex))->startBlink(); // 更新索引 _selectedPhotoIndex = _selectPhotoStartIndex; _selectPhotoStartIndex = -1; } break; } default: break; } }
void TrialPanel::selectedItemEvent(Ref *pSender, ListView::EventType type) { switch (type) { case cocos2d::ui::ListView::EventType::ON_SELECTED_ITEM_START: { ListView* listView = static_cast<ListView*>(pSender); CC_UNUSED_PARAM(listView); CCLOG("select child start index = %ld", listView->getCurSelectedIndex()); //auto tag = listView->getItem(listView->getCurSelectedIndex())->getTag(); //auto endStatUnit = _endStatsUnit.at(listView->getCurSelectedIndex()); break; } case cocos2d::ui::ListView::EventType::ON_SELECTED_ITEM_END: { ListView* listView = static_cast<ListView*>(pSender); CC_UNUSED_PARAM(listView); CCLOG("select child end index = %ld", listView->getCurSelectedIndex()); /*auto unit = listView->getItem(listView->getCurSelectedIndex()); auto achieve = static_cast<Achievement*>(unit->getUserData());*/ break; } default: break; } }
void HudPanel::selectedBuffEvent(Ref *pSender, ListView::EventType type) { switch (type) { case cocos2d::ui::ListView::EventType::ON_SELECTED_ITEM_START: { ListView* listView = static_cast<ListView*>(pSender); CC_UNUSED_PARAM(listView); CCLOG("select child start index = %ld", listView->getCurSelectedIndex()); //auto tag = listView->getItem(listView->getCurSelectedIndex())->getTag(); //auto endStatUnit = _endStatsUnit.at(listView->getCurSelectedIndex()); break; } case cocos2d::ui::ListView::EventType::ON_SELECTED_ITEM_END: { ListView* listView = static_cast<ListView*>(pSender); CC_UNUSED_PARAM(listView); CCLOG("select child end index = %ld", listView->getCurSelectedIndex()); auto buffUnit = static_cast<BuffUnit*>(listView->getItem(listView->getCurSelectedIndex())); auto buffPan = BuffPanel::create("buff"); buffPan->initWithBuff(buffUnit->getBuff()); PopPanel::getInstance()->addPanel(buffPan, 2); break; } default: break; } }
void ShopPanel::selectedItemEvent(Ref *pSender, ListView::EventType type) { switch (type) { case cocos2d::ui::ListView::EventType::ON_SELECTED_ITEM_START: { ListView* listView = static_cast<ListView*>(pSender); CC_UNUSED_PARAM(listView); CCLOG("select child start index = %ld", listView->getCurSelectedIndex()); //auto tag = listView->getItem(listView->getCurSelectedIndex())->getTag(); //auto goodUnit = _goodsUnit.at(listView->getCurSelectedIndex()); break; } case cocos2d::ui::ListView::EventType::ON_SELECTED_ITEM_END: { ListView* listView = static_cast<ListView*>(pSender); CC_UNUSED_PARAM(listView); CCLOG("select child end index = %ld", listView->getCurSelectedIndex()); auto goodUnit = _goodsUnit.at(listView->getCurSelectedIndex()); auto good = goodUnit->getGood(); PopPanel::getInstance()->confirm("buy","type:Text---text:"+ a2u("确定要花费 ") + cocos2d::Value(goodUnit->getPrice()).asString() + a2u("元 购买 ") + cocos2d::Value(goodUnit->getNum()).asString() + a2u("个") + good->getNickName() + a2u(" 吗?"),PromptPanel::TYPE_DONE_CANCEL,[=](){ // 加速药水 if(good->getTypeId() == 2003011 && Detect::shareDetect()->getUser()->getBuffByTypeId(4001001) != nullptr) { PopPanel::getInstance()->note("treaMap","type:Text---text:"+ a2u("已拥有该效果"),2.0f,false,true); } else { #if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID //确定购买 JniMethodInfo jmi; if(JniHelper::getStaticMethodInfo(jmi ,"IAP/IAPJni" ,"orderGood" ,"(I)V")) { jmi.env->CallStaticVoidMethod(jmi.classID , jmi.methodID, listView->getCurSelectedIndex()); } #else JniTest::getInstance()->orderSuccess(listView->getCurSelectedIndex()); #endif } },nullptr,true,true); break; } default: break; } }
// ListView触摸监听 void TujiLayer::selectedItemEvent(Ref* pSender, ListViewEventType type)//ListView触摸事件 { ListView* listView = static_cast<ListView*>(pSender); CC_UNUSED_PARAM(listView); // if (m_iBeforeSel == listView->getCurSelectedIndex()) // { // return; // } // String *normalBtn = String::createWithFormat("Cell_%d.png", m_iBeforeSel); // String *SelctBtn = String::createWithFormat("CellSel_%d.png", listView->getCurSelectedIndex()); m_iBeforeSel = listView->getCurSelectedIndex(); switch (m_iBeforeSel) { case 0: m_pMZ_Pic->setVisible(true); m_pMZ_Txt->setVisible(true); m_pMZLabel->setVisible(true); m_pLion_Pic->setVisible(false); m_pLionLabel->setVisible(false); m_pStone_Pic->setVisible(false); m_pStoneLabel->setVisible(false); break; case 1: m_pMZ_Pic->setVisible(false); m_pMZLabel->setVisible(false); m_pMZ_Txt->setVisible(false); m_pLionLabel->setVisible(true); m_pLion_Pic->setVisible(true); m_pStoneLabel->setVisible(false); m_pStone_Pic->setVisible(false); break; case 2: m_pMZ_Pic->setVisible(false); m_pMZ_Txt->setVisible(false); m_pMZLabel->setVisible(false); m_pLion_Pic->setVisible(false); m_pLionLabel->setVisible(false); m_pStone_Pic->setVisible(true); m_pStoneLabel->setVisible(true); break; case 3: m_pMZ_Pic->setVisible(false); m_pMZ_Txt->setVisible(false); m_pLion_Pic->setVisible(false); m_pStone_Pic->setVisible(false); m_pLionLabel->setVisible(false); m_pStoneLabel->setVisible(false); m_pMZLabel->setVisible(false); break; default: break; } }
void UIListViewTest_Horizontal::selectedItemEvent(Ref *pSender, ListView::EventType type) { switch (type) { case cocos2d::ui::ListView::EventType::ON_SELECTED_ITEM_START: { ListView* listView = static_cast<ListView*>(pSender); CC_UNUSED_PARAM(listView); CCLOG("select child start index = %ld", listView->getCurSelectedIndex()); break; } case cocos2d::ui::ListView::EventType::ON_SELECTED_ITEM_END: { ListView* listView = static_cast<ListView*>(pSender); CC_UNUSED_PARAM(listView); CCLOG("select child end index = %ld", listView->getCurSelectedIndex()); break; } default: break; } }
void TodayScene::selectedItemEvent(Ref *pSender, ListViewEventType type) { switch (type) { case cocos2d::ui::LISTVIEW_ONSELECTEDITEM_START: { ListView* listView = static_cast<ListView*>(pSender); CC_UNUSED_PARAM(listView); CCLOG("select child start index = %ld", listView->getCurSelectedIndex()); break; } case cocos2d::ui::LISTVIEW_ONSELECTEDITEM_END: { ListView* listView = static_cast<ListView*>(pSender); CC_UNUSED_PARAM(listView); CCLOG("select child end index = %ld", listView->getCurSelectedIndex()); xSM->forward(SCENE_DETAIL, listView->getCurSelectedIndex(), nullptr); break; } default: break; } }
void TestTitleList::titleListEventListener(Ref* sender, ui::ListView::EventType eventType) { ListView* listView = static_cast<ListView*>(sender); switch (eventType) { case ListView::EventType::ON_SELECTED_ITEM_START: { printf("listView start selectedIdx = %ld\n" , listView->getCurSelectedIndex()); } break; case ListView::EventType::ON_SELECTED_ITEM_END: { printf("listView end selectedIdx = %ld\n" , listView->getCurSelectedIndex()); Scene* scene = getSceneByModuleName(testmoduleNames.at(listView->getCurSelectedIndex())); if (scene) { Director::getInstance()->pushScene(scene); } } break; default: break; } }