码迷,mamicode.com
首页 > 移动开发 > 详细

android平台菜单返回键监听

时间:2016-05-21 20:15:43      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:

//声明

void onKeyReleased(EventKeyboard::KeyCode keyCode, Event* event);

//实现

//按键控制(检测onKeyReleased有反应)
auto listener = EventListenerKeyboard::create();
listener->onKeyReleased = CC_CALLBACK_0(MenuLayer::onKeyReleased, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
void MenuLayer::onKeyReleased(EventKeyboard::KeyCode keyCode, Event* event)
{
    switch(keyCode)
    {
    //监听返回键
    case EventKeyboard::KeyCode::KEY_ESCAPE:

         Director::getInstance()->end();
        break;
    //监听menu键
    case EventKeyboard::KeyCode::KEY_MENU:
        break;
    }
} 

 

android平台菜单返回键监听

标签:

原文地址:http://www.cnblogs.com/kingBook/p/5515372.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!