I'm developing a simple menubar app for OS X Yosemite using Swift. What is I need is to show Preferences window (when user clicks on menu item) Window should be hidden at launch, and should be shown when user calls it.
I found an example which implements the same thing that I need: http://www.johnmullins.co/blog/2014/08/08/menubar-app/
This is a piece of code from my app:
class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var buildStatusMenu: NSMenu!
@IBOutlet weak var preferencesWindow: NSWindow!
let statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(-1)
func applicationDidFinishLaunching(aNotification: NSNotification) {
self.preferencesWindow!.orderOut(self)
}
func showPreferencesWindow(sender: AnyObject?) {
self.preferencesWindow!.orderFront(self)
NSLog("Show window")
}
orderOut works correctly, and I don't see window at launch but when I try to call showPreferencesWindow(), nothing happens. (But I see a record in log) I'm sure there is no magic here, I'm just doing something wrong. Can someone help me? Thanks in advance.