3

In my OSX menubar application, the user can open a particular application NSWindow from a dropdown menu item. Being a menubar application, this is accessible from any Desktop (a Desktop as in a Mission Control 'Space').

I've got a reference to the window programmatically.

Say the user has clicked the menu item while on Desktop 1, the currently active Desktop. Naturally, the NSWindow is created, opened, brought to front. It now lives on Desktop 1

The user browses to Desktop 2, so that it's now the active Desktop.

The user clicks on the menu item again.

Since the window is already open on Desktop 1, I'd like Spaces to automatically bring set the active Desktop to Desktop 1 again, so that the user can see the window he/she wanted to see.

How do I programmatically achieve this with Objective-C Cocoa in OSX?

fatuhoku
  • 4,815
  • 3
  • 30
  • 70
  • Does `[NSApp activateIgnoringOtherApps:YES]` not work for menu bar applications? – ianyh Aug 19 '13 at 22:49
  • Did you figure this one out man? Im trying to do same, I have PID of window i want to focus and now need to ensure the desktop is focused then the window is focused. – Noitidart Oct 04 '14 at 05:01
  • Sadly I no longer work on the project that prompted the question. I don't think I did find a solution. – fatuhoku Oct 04 '14 at 08:39

0 Answers0