I have an app that sits in the menu bar, and when you click on the button it presents an NSPopover.
That all works fine, but I want an NSSearchField to become the first responder, so a user can then type straight in the box.
However, if the app was not already selected, it won't work. And although it looks like the search box is active, the keyboard input goes to the previous app that was open, because technically it is still the active window.
I've seen a few questions about things like this, but they all require objc methods like makekeyandorder, or just stuff that won't apply to an NSPopover.
So my question is - Is there a way that when the button is pressed, I can then force the application to become the active app?
I had a wild guess and tried NSApplication().sharedApplication().becomeFirstResponder()
, but no luck.
If there's another way to do it, that I've just missed completely, then please let me know!