Cocoa: NSUserNotification appears behind NSPopover

I don't know where to even start trying to fix this, but maybe someone can point me in the right direction. I have a state element app that shows a popover when clicked, some user interactions create an NSUserNotification to alert / notify about changes or errors. But when the notification appears, it is displayed behind the popover, so if they overlap, the user cannot read what he is saying.

Is there a way to make the notification appear before the popover? How to order notification to the front.

Edit: Here's an image displaying part of the notification hidden behind the popover after the user has given bad input. I really don't want to hide the popover to show the error notification.

I've tried things makeKeyAndOrderFront, makeIgnoringOtherApps, the type of stuff you will be using in the window, but none of them apply to NSUserNotification, so it doesn't work.

Edit 2: I should note that in order for the popup to appear in front of everything when called, I use activateIgnoringOtherApps and startFirstResponder on the popover, but even getting rid of that still shows the notification behind the popover.

Edit 3: Checkout is displayed relative to the status element in the status bar using [[self popover] showRelativeToRect:statusItem.view.bounds ofView:statusItem.view preferredEdge:NSMaxYEdge];

On click, the status element invokes a method that does this:

- (void)openPopover:(id)sender {
if (![_popover isShown] | (_popoverIsClosing)) {
    [_preferencesWindow close];
    [NSApp activateIgnoringOtherApps:YES];
    [_popover becomeFirstResponder];
    [statusItemView setHighlighted:YES];
    [[self popover] showRelativeToRect:statusItem.view.bounds ofView:statusItem.view preferredEdge:NSMaxYEdge];
    [self performSelector:@selector(defaultTextField)];
    NSLog(@"popover opened");

} else {
    [_preferencesWindow close];
    [NSApp activateIgnoringOtherApps:NO];
    NSLog(@"popover closed");
    [_popover close];
    [_popover resignFirstResponder];
    [[NSApplication sharedApplication] hide: self];
    [statusItemView setHighlighted:NO];
}

      

}

Thanks for the help.

+3


source to share





All Articles