title: Can NSAlert Be Used to Create a Floating Window?
body: <p>I have a Cocoa application that displays an application-modal alert using the <code>NSAlert</code> class. I'd like the alert window to float above all other applications' windows.  Can this be done with <code>NSAlert</code>, or do I need to implement my own window?</p>
  
  <p>I don't know if any of this matters, but the application is an agent application (<code>LSUIElement</code> is true) implemented as an <code>NSStatusItem</code>. (For more info about the app, including source code, look <a href="http://capablehands.net/menubarcountdown" rel="noreferrer">&lt;here></a>.)</p>
  
  <p>Here is the code that displays the alert:</p>
  
  <pre><code>- (void)showTimerExpiredAlert {
      [NSApp activateIgnoringOtherApps:YES];
  
      NSAlert *alert = [[NSAlert alloc] init];
      [alert setAlertStyle:NSInformationalAlertStyle];
      [alert setMessageText:NSLocalizedString(@"Menubar Countdown Complete", @"Expiration message")];
      [alert setInformativeText:NSLocalizedString(@"The countdown timer has reached 00:00:00.",
                                                  @"Expiration information")];
      [alert addButtonWithTitle:NSLocalizedString(@"OK", @"OK button title")];
      [alert addButtonWithTitle:NSLocalizedString(@"Restart Countdown...", @"Restart button title")];
  
      NSInteger clickedButton = [alert runModal];
      [alert release];
  
      if (clickedButton == NSAlertSecondButtonReturn) {
          // ...
      }
  }
  </code></pre>
  
  <p>I've tried putting this before the <code>runModal</code> call:</p>
  
  <pre><code>[[alert window] setFloatingPanel:YES];
  </code></pre>
  
  <p>I've also tried this:</p>
  
  <pre><code>[[alert window] setLevel:NSFloatingWindowLevel];
  </code></pre>
  
  <p>But neither of those makes the window stay above others if I click another application's window.  I suspect <code>runModal</code> just doesn't honor either of those settings.</p>