0
votes

In my app I have windows that display notifications. I instantiate the controller from a xib and I call makeKeyAndOrderFront to make the window visible. I also adjust its level to NSScreenSaverWindowLevel so that it appears in front of others.

The problem is, when I click this window to use it, the main window for my app comes to front. I also have other Windows my app opens, and I noticed that the same behavior happens to them.

According to Apple's documentation on NSWindow, bringing a window to the front should not change the order of any other Windows, thus my confusion.

2

2 Answers

0
votes

Alternatives

Have you considered using NSAlert to display those notifications?

I don't know what you want to show to the user, but if it is only a notification, NSUserNotification is a nice way too. The user gets informed, but not interrupted from what he is doing.

0
votes

Turns out the issue is related to this other question. An important piece I failed to mention here is that the windows in my app that exhibited this issue were titlebar-less.

By default, when you have a titlebar-less window, Cocoa doesn't allow it to become the main window. I subclassed NSWindow and overrode canBecomeMainWindow to return YES at all times and this solved my problem.

This also explained why my windows were resizable but the resize handles never showed up on their own; only main windows get resize handles!