【发布时间】:2014-11-30 15:37:09
【问题描述】:
我正在为 Mac OS X 制作状态栏应用程序,但是我只希望在单击状态栏项目时刷新它。
这是我的代码:
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
}
}
如果有人可以帮助我做到这一点,将不胜感激。
【问题讨论】: