No, really. What is the proper way to handle keyboard input in a game using Cocoa?

前端 未结 2 2166
醉酒成梦
醉酒成梦 2021-02-07 07:29

Let\'s say you\'re creating a game for Mac OS X. In fact, let\'s say you\'re creating Quake, only it\'s 2011 and you\'d prefer to only use modern, non-deprecated frameworks.

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-07 07:47

    This looks promising:

    +[ NSEvent addLocalMonitorForEventsMatchingMask:handler: ]

    Seems to be new in 10.6 and sounds just like what you're looking for. More here:

    http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSEvent_Class/Reference/Reference.html%23//apple_ref/occ/clm/NSEvent/addLocalMonitorForEventsMatchingMask:handler:

提交回复
热议问题