码迷,mamicode.com
首页 > Windows程序 > 详细

cocos2d-x3.x windows环境下 textfield无法处理TEXTFIELD_EVENT_DELETE_BACKWARD事件

时间:2014-08-29 17:38:48      阅读:254      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   color   os   io   ar   for   div   

1、修改cocos2d-x-3.x\cocos\2d\platform\desktop\CCGLView.cpp   onGLFWKeyCallback函数 

 1 static void onGLFWKeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods)
 2     {
 3         if (_view)
 4             _view->onGLFWKeyCallback(window, key, scancode, action, mods);
 5             
 6         if (GLFW_REPEAT != action) 
 7         {
 8             EventKeyboard event(g_keyCodeMap[key], GLFW_PRESS == action);
 9             if ((EventKeyboard::KeyCode::KEY_BACKSPACE == event._keyCode) && event._isPressed) 
10             {  
11                 IMEDispatcher::sharedDispatcher()->dispatchDeleteBackward();  
12             }   
13             else  
14             { 
15                 auto dispatcher = Director::getInstance()->getEventDispatcher();  dispatcher->dispatchEvent(&event); 
16             }  
17         } 
18     }

2、在CCGLView.cpp中 把声明g_keyCodeMap放到最前面, 如下这句:

1 static std::unordered_map<int, EventKeyboard::KeyCode> g_keyCodeMap;

3、修改cocos2d-x-3.x\cocos\2d\CCEventKeyboard.h

1 public:
2     KeyCode _keyCode;
3     bool _isPressed;
4     
5 private:
6     friend class EventListenerKeyboard;

 

cocos2d-x3.x windows环境下 textfield无法处理TEXTFIELD_EVENT_DELETE_BACKWARD事件

标签:des   style   blog   color   os   io   ar   for   div   

原文地址:http://www.cnblogs.com/atong/p/3945297.html

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