NSView不会收到mouseDown

时间:2014-07-21 23:03:58

标签: macos cocoa swift desktop-application

我的自定义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

0 个答案:

没有答案