2

Right now I'm developing a Status Bar Application and I need to know when the app loses focus, every time. So I am currently using applicationDidResignActive: for that but that's not catching when I open another Status Bar App's menu.
How can I make applicationDidResignActive: (or any other method) catch every time my app loses focus, even when opening another Status Bar App?

Pedro Vieira
  • 3,330
  • 3
  • 41
  • 76
  • would it help if you you are listening to NSApplicationNotifications (willHide/Unhide instead of resignActive) ?https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSApplication_Class/Reference/Reference.html#//apple_ref/doc/uid/20000012-BAJDHBID (ps: I haven't done any Mac OS programming, but on iOS, i have found UIApplicationNotificaitions are much more helpful) – Nitin Alabur Dec 31 '12 at 16:31

1 Answers1

3

I think what you're actually looking for is when the window looses focus.

You can use the following NSWindowDelegate method:

windowDidResignMain:

You also have to set canBecomeMainWindow to YES

- (BOOL)canBecomeMainWindow {
    return YES;
}

Make sure to connect it to the delegate and you should be fine.

IluTov
  • 6,807
  • 6
  • 41
  • 103