1

I have a custom NSPanel: http://cl.ly/K8SY

I have it set to NSPopUpMenuWindowLevel, the level at which I want it to stay as. An example is the spotlight menu, when you click on it any other focus in the windows in the background remains yet you can still type into the search field.

I open it with:

[window orderFront:nil]

but this doesn't focus on the window as well as the background.

Is it possible to achieve this? If so, how?

Luke
  • 4,908
  • 1
  • 37
  • 59

1 Answers1

1

You need to use the -[NSWindow makeKeyAndOrderFront:] call instead.

NOTE: keyboard focus can only be directed at one view in one window. Cocoa's notion of mainWindow and keyWindow can be different windows, but its only the first responder within the keyWindow that accepts keyboard input.

Mark Alldritt
  • 597
  • 1
  • 4
  • 9
  • I used [window makeKeyAndOrderFront:self]; but still didn't work. I'm not using a text field so I don't need to worry about keyboard focus, it's a NSTableView that I would like to add focus to. – Luke Oct 14 '12 at 20:58
  • Have you tried using -[NSWindow makeFirstResponder:] to force the NSTableView instance to become the transparent window's first responder? – Mark Alldritt Oct 14 '12 at 21:59
  • They only way I can get the tableview to gain focus on makeKeyAndOrderFront is with [NSApp activateIgnoringOtherApps:YES];, other than that it won't gain focus – Luke Oct 15 '12 at 15:29