//宣告void touchButton(Object* object,TouchEventType type);//掛接到控制元件上uiButton->addTouchEventListener(this,toucheventselector(HelloWorld::touchButton));//實現void HelloWorld::touchButton(Object* object,TouchEventType type){ LabelTTF* label; switch (type) { case TouchEventType::TOUCH_EVENT_BEGAN: label = static_cast<LabelTTF*>(getChildByTag(11)); label->setString("按下按鈕"); break; case TouchEventType::TOUCH_EVENT_MOVED: label = static_cast<LabelTTF*>(getChildByTag(11)); label->setString("按下按鈕移動"); break; case TouchEventType::TOUCH_EVENT_ENDED: label = static_cast<LabelTTF*>(getChildByTag(11)); label->setString("放開按鈕"); break; case TouchEventType::TOUCH_EVENT_CANCELED: label = static_cast<LabelTTF*>(getChildByTag(11)); label->setString("取消點選"); break; default: break; }}你需要實現onclick()
//宣告void touchButton(Object* object,TouchEventType type);//掛接到控制元件上uiButton->addTouchEventListener(this,toucheventselector(HelloWorld::touchButton));//實現void HelloWorld::touchButton(Object* object,TouchEventType type){ LabelTTF* label; switch (type) { case TouchEventType::TOUCH_EVENT_BEGAN: label = static_cast<LabelTTF*>(getChildByTag(11)); label->setString("按下按鈕"); break; case TouchEventType::TOUCH_EVENT_MOVED: label = static_cast<LabelTTF*>(getChildByTag(11)); label->setString("按下按鈕移動"); break; case TouchEventType::TOUCH_EVENT_ENDED: label = static_cast<LabelTTF*>(getChildByTag(11)); label->setString("放開按鈕"); break; case TouchEventType::TOUCH_EVENT_CANCELED: label = static_cast<LabelTTF*>(getChildByTag(11)); label->setString("取消點選"); break; default: break; }}你需要實現onclick()