title: Swift: Refresh menu bar on click
body: <p>I am making a status bar application for Mac OS X however I only want it to refresh when I click the status bar item.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>class AppDelegate: NSObject, NSApplicationDelegate {
      @IBOutlet weak var window: NSWindow!
      @IBOutlet var menu: NSMenu!
  
  
      var statusItem: NSStatusItem!;
  
      @IBAction func quit(sender: AnyObject) {
          NSApplication.sharedApplication().terminate(nil)
      }
  
      func Refresh(){
          NSLog("Refresh")
      }
  
      func applicationDidFinishLaunching(aNotification: NSNotification?) {
          statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(-1)
          statusItem.title = "Battery Infomation"
          statusItem.menu = self.menu
          statusItem.highlightMode = true
      }
  
      func applicationWillTerminate(aNotification: NSNotification) {
          // Insert code here to tear down your application
      }
  
  
  }
  </code></pre>
  
  <p>If any one can help me to do this that would be appreciated.</p>