Colen
Colen

Reputation: 13898

Bring child windows to the front with Cocoa

In our application, the user can open a number of small, non-modal windows that "float" around the main application. Each of these windows can be resized, moved, etc. When the user clicks the main application window to bring it to the front, we'd like to also bring the small floating windows to the front.

Is there an event or something that I can track for when "application becomes active"? The equivalent on windows would be the WM_ACTIVATEAPP message, but I'm not sure where to look in Cocoa.

Upvotes: 0

Views: 412

Answers (2)

Joshua Nozzi
Joshua Nozzi

Reputation: 61228

I believe if you use NSPanel (a type of window), you get this behavior for free. If your windows are in support of the main window (and should always accompany it), they should be panels, not regular windows. You can even have them visible only when the app is active and they hide and don't participate in Expose when the app does not have focus to reduce clutter.

Upvotes: 2

jscs
jscs

Reputation: 64002

Your application delegate receives applicationDidBecomeActive: when, um, the application becomes active. If you're using the default Xcode templates, you should already have an object that is your app delegate.

Upvotes: 1

Related Questions