我已经创建了一个菜单栏'button‘,当它被点击时,它会运行一个函数。下面是我的菜单栏按钮代码。
let statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(-1)
func applicationDidFinishLaunching(aNotification: NSNotification) {
if let button = statusItem.button {
button.title = "This is in the menu bar."
button.action = Selector("myFunction")
}
}问题是,这将成为一个图像,而不是文本,所以当用户单击它时,我需要它不被突出显示为蓝色,这就是目前发生的情况。
当用户点击它时,我可以做什么来阻止它被高亮显示吗?
谢谢!
发布于 2015-08-27 20:25:15
我猜您可以将按钮类型设置为MomentaryChangeButton,这是一种在单击时不会突出显示的按钮类型。
button.setButtonType(NSButtonType.MomentaryChangeButton)简短语法:
button.setButtonType(.MomentaryChangeButton)如果您还想摆脱对焦环:
button.focusRingType = NSFocusRingType.None简短语法:
button.focusRingType = .None注意:我写了“我猜”,因为我没有验证它在状态栏按钮的特定情况下是否有效。
https://stackoverflow.com/questions/32248675
复制相似问题