2

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

ergosys
  • 47,835
  • 5
  • 49
  • 70
David
  • 43
  • 3

2 Answers2

3

Have you tried using NSWindow makeFirstResponder method to make your NSOpenGLView the first responder?

Julio Gorgé
  • 10,056
  • 2
  • 45
  • 60
  • Thanks Julio, I had been looking at makeFirstResponer for the past few hours but getting no where. Then here[link](http://www.zerobyzero.ca/~ktatters/tutorials/tutorial0.html), I found reference to calling make responder from [NSApp keyWindow] and I managed to get it working. Just had to add '[[NSApp keyWindow] makeFirstResponder: MyOpenGLView];' at the end of my button call function. Thanks. – David Feb 03 '11 at 02:01
  • Glad to help, don't forget to mark my answer as correct! It will help grow my e-penis and help future visitors ;) – Julio Gorgé Feb 03 '11 at 02:34
2

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)

David
  • 43
  • 3