我在OS中构建菜单栏项目时发现了一些示例代码。它使用了单个|,但我不确定它的实际含义。
(我正在尝试做的是让一个函数在菜单项左键单击时调用,但让它在右键单击时显示菜单)
这是我的代码
//Get reference to main system status bar
let statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(-1)
statusItem.image = icon
statusItem.menu = menuBar
if let statusButton = statusItem.button
{
statusButton.target = self
statusButton.action = #selector(statusItemClicked)
statusButton.sendActionOn(Int(NSEventMask.RightMouseUpMask.rawValue | NSEventMask.LeftMouseUpMask.rawValue))
}发布于 2016-08-06 12:49:57
按位或,就像在大多数类C语言中一样。在这种情况下,它被用来组合标志。
https://stackoverflow.com/questions/38800622
复制相似问题