NSWindow 的 -toggleFullScreen:方法失去键盘焦点?
我正在编写一个应用程序,启动时会显示一个选项屏幕,然后进入全屏模式。但是,一旦进入全屏,键盘焦点就会丢失,用户必须单击鼠标才能重新获得焦点。这不是什么大问题,只是带有计时器的游戏会立即开始,而因此损失的几秒钟可能很重要。有什么办法可以自动重新获得键盘焦点吗?
I am writing an application 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 NSWindow
-makeFirstResponder:
一旦进入全屏。通过您想要关注的响应者。You can use NSWindow
-makeFirstResponder:
once your full screen enters. Pass the responder that you want focused.您需要设置作为第一响应者访问事件的任何需要。如果 NSWindow 是全屏的,它会自动成为响应者链中的第一个。
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.