views:

20

answers:

0

Hi,

I've got an application that needs to become the front most application after a timer expires and resign the front most status when the timer is started by pressing a button, e.g.

  • click "start timer" -> app resigns front most application
  • timer expires -> app becomes front most application

I deliberately paraphrased things a little because playing with active status of the sharedApplication doesn't do what I want.

I become the front most app by doing a [[NSApplication sharedApplication] activateIgnoringOtherApps: YES] and that works perfectly well.

Doing the reverse seems impossible!?

  • [[NSApplication sharedApplication] deactivate] shouldn't be called directly, but more importantly doesn't bring the next application in the "command-tab order" forwards. The app just sits there with its menu bar showing but it's no longer "active".

  • [[NSApplication sharedApplication] hide: self] resigns the active status and brings the next application in the "Command-tab order" to the front BUT it also hides all the application windows.

I need some way of bringing the next application in the command-tab order to the front WITHOUT hiding all my windows.

Is there a good way of doing that?

The solution should be 10.5 Leopard and 10.6 compatible.

I do have a solution from around 1996 but it involves Carbon APIs and I'd really prefer doing it the Cocoa or at least Foundation way..

Any help would be greatly appreciated.