cocos2d / cocos2d-x

Cocos2d-x is a suite of open-source, cross-platform, game-development tools utilized by millions of developers across the globe. Its core has evolved to serve as the foundation for Cocos Creator 1.x & 2.x.
https://www.cocos.com/en/cocos2d-x
18.24k stars 7.06k forks source link

EventListenerKeyboard not working on ios simulator #17576

Open kibozh opened 7 years ago

kibozh commented 7 years ago
  1. create a new lua project
  2. add the following code to function MainScene:onCreate()
    local listener = cc.EventListenerKeyboard:create()
    listener:registerScriptHandler(function (keyCode, event )
        print("get key event")
    end, cc.Handler.EVENT_KEYBOARD_RELEASED)
    local eventDispatcher = self:getEventDispatcher()
    eventDispatcher:addEventListenerWithSceneGraphPriority(listener, self)

    3.just build and run and then press any key, nothing print in xcode's console

minggo commented 7 years ago

Where to popup the keyboard?

nickenchev commented 6 years ago

There are hardware keyboards for iphones and ipads, the simulator emulates a hardware keyboard. I'm also not getting any keyboard events when running in iOS simulator.