首页 > 代码库 > cocos2d-x3.x windows环境下 textfield无法处理TEXTFIELD_EVENT_DELETE_BACKWARD事件
cocos2d-x3.x windows环境下 textfield无法处理TEXTFIELD_EVENT_DELETE_BACKWARD事件
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事件
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。