0

I am making a vim-style "window manager" that takes text input, much like Alfred or Spotlight in Mavericks (in a floating panel).

The problem I'm having is when I call activateWithOptions: on a running application it steals focus from my window. I was hoping the problem would be solved by simply bring my app to the foreground again, however it seems the activation is running on a separate thread, and I end up activating my app before the original app gets activated.

I have tried reactivating when I receive NSWorkspaceDidActivateApplicationNotification, but that doesn't work either.

Ideally I'd like to pause execution until the application is focused for multiple reasons, since that would be the window I manipulate further.

Does anyone have any suggestions?

Keenle
  • 12,010
  • 3
  • 37
  • 46
hannesr
  • 449
  • 5
  • 12
  • You probably want your window to be an `NSPanel` whose style mask includes `NSNonactivatingPanelMask`. Then it can have focus without its owning app being active. – Ken Thomases Jul 17 '14 at 20:15
  • That part I have done, so another app seems to be focused behind. The problem begins when I call another app to the front, I loose that... – hannesr Jul 17 '14 at 20:38
  • What about `-[NSWindow setLevel:]`? – tsnorri Jul 20 '14 at 20:27

0 Answers0