Search code examples
objective-cmacosdialogmodal-dialognswindowcontroller

Pop dialog in front of an active open file dialog


When the user opens some files, I use the open event in order to make some operations before enabling him to actually open. For that I have a progress dialog.

However, my dialog is always opened behind the open file dialog.

I've added the following code to windowDidLoad of my NSWindowController:

[NSApp activateIgnoringOtherApps:YES];
[[NSApplication sharedApplication] runModalForWindow:self.window];

But it didn't make any impact.

Open dialog: Open dialog

How can I display my dialog in front? Note that my dialog is opened after it and closed before it.


Solution

  • With the help from the comments, I found that adding the following line before showing the window resolved the issue:

    self.window.level = NSPopUpMenuWindowLevel;