将焦点从 NSTextField 更改为 NSOpenGLView?
我正在使用 Interface Builder 在 Mac 上开发 OpenGL 模拟的界面。所有 OpenGL 的东西都是用 C++ 编写的(我对此非常了解)。不幸的是我对 Objective-C 不了解。
基本上,我有一些 NSTextField 显示屏幕上所选对象的信息。使用这些文本字段,用户能够操作屏幕上的对象,然后有一个“保存”按钮和一个“恢复”按钮(保存新值或恢复原始值),
我可以让这一切正常工作。我的问题是,当我将数据输入 NSTextField 时,窗口的“焦点”似乎保留在 NSTextField 上(蓝色边框保留在其周围)。
我使用键盘与 NSOpenGLView 中的项目进行交互,当我点击“保存”或“恢复”按钮时,我需要将焦点传递回 NSOpenGLView。
抱歉,如果这是一个非常简单的问题,
谢谢
大卫
I am developing an interface for an OpenGL Simulation on the Mac using Interface Builder. All OpenGL stuff is being written in C++ (which I know fairly well). Unfortunately I have no idea about Objective-C.
Basically, I have a few NSTextField displaying info on an object selected on the Screen. Using these textfields the user is the able to manipulate the object on screen and then there is a Save Button and a Restore Button (which either save the new values or restore the original ones)
I have this all working. My problem is when I enter data into an NSTextField the "focus" of the windows seems to remain on the NSTextField (blue border remains around it).
I use the keyboard to interact with items within the NSOpenGLView, I need to pass the focus back to the NSOpenGLView when I hit either the Save or Restore buttons.
Sorry if this is a very straightforward question
Thanks
David
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过使用 NSWindow makeFirstResponder 方法使您的 NSOpenGLView 成为第一响应者?
Have you tried using NSWindow makeFirstResponder method to make your NSOpenGLView the first responder?
刚刚设法让它工作。
我必须添加以下行:
[[NSApp keyWindow] makeFirstResponder: MyOpenGLView];
当我单击任一按钮时,到调用函数的末尾。
(感谢胡里奥为我指明了正确的方向)
Just managed to get it working.
I had to add the line:
[[NSApp keyWindow] makeFirstResponder: MyOpenGLView];
to the end of the function being called when I click on either of my buttons.
(Thanks Julio for pointing me in the right direction)