开发者

NSWindow's -toggleFullScreen: method loses keyboard focus?

开发者 https://www.devze.com 2023-03-28 00:30 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号