我的自定义NSView目前无视我处理mouseDown
事件的尝试......
class MainButton: NSView {
override func acceptsFirstMouse(theEvent: NSEvent!) -> Bool {
return true
}
override func mouseDown(theEvent: NSEvent!) {
let alert = NSAlert()
alert.messageText = "Testing..."
alert.runModal()
}
override func drawRect(rect: NSRect) {
super.drawRect(rect)
// more custom drawing
}
}
有没有明显的理由在点击绘制的视图时不会触发mouseDown
函数?
此外,我可以确认永远不会调用acceptsFirstMouse
。