Reputation: 2282
I'm developing a small menubar application and I want to display the settings window when the corresponding NSMenuItem is pressed.
I currently have the following IBAction assigned to the menu item:
@IBAction func settingsButtonPressed(sender: NSMenuItem) {
settingsView.makeKeyAndOrderFront(sender)
}
This displays the window, but doesn't push it into focus, so it's displayed behind the currently active window, which is not the behaviour I'm looking for.
I had a suspicion that this might have been due to the fact that the Application is agent
target property is set to YES
, but this actually has no effect on the outcome.
Could there be anything to be done with the window in the XIB file?
Upvotes: 0
Views: 429
Reputation: 90531
Probably your app is not the active app. It should work to call [NSApp activateIgnoringOtherApps:YES]
in addition to making the window key and ordering it front.
Upvotes: 1