I am writing an applicat开发者_JAVA技巧ion which when launched, shows an options screen, then proceeds to enter fullscreen mode. However, once in fullscreen, keyboard focus is lost and the user has to click the mouse to regain it. This wouldn't be much of a problem, except that a game with a timer starts immediately, and the couple of seconds that are lost with this could be important. Is there any way to regain keyboard focus automatically?
You can use NSWindow -makeFirstResponder:
once your full screen enters. Pass the responder that you want focused.
You need to set whatever needs to access the events as the first responder. If a NSWindow is fullscreen it automatically is the first in the responder chain.
精彩评论