Cocoa - How to bring particular window to come in foreground from StatusMenu

488 Views Asked by At

I am working on an Mac Application. I have set Application is agent (UIElement) = YES in plist, and App have a Window (lets say Popup Window) that acts as custom PopOver for StatusMenu. One more window is there (lets say Window B) that should opened on selecting a Link from StatusMenu that i have made, but Problems that I am facing are as follow:

  • On Application launch, When I opens status Menu It also showing Window B, that actually should not be Shown. Window B is allocated and initialised in Application Delegate.

  • Another Issue is When Window B is made Visible by Selecting it from StatusMenu. It appears well, Now i switch to another application so Its window is sent to background that is fine, but Whenever I click on Status Menu, It automatically comes in Front. Ideally It should only open Popup window.

1

There are 1 best solutions below

0
On BEST ANSWER
  • Window B is opening because you might be forgot to un-check "Visible At Launch" window property in attribute inspector of interface builder

enter image description here

  • 2nd issue you can resolve by activateIgnoringOtherApps set to YES before calling your window

    [[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
    
    [windowB showWindow:nil];