Cocoa: change cursor when it's over an NSButton

前端 未结 5 782
一整个雨季
一整个雨季 2020-12-01 14:26

How can I change the cursor when it\'s over an NSButton?

5条回答
  •  佛祖请我去吃肉
    2020-12-01 15:16

    Following the already given example, creating a subclass of NSButton in Swift 5:

    import AppKit
    
    class Button: NSButton {
        override func resetCursorRects() {
            addCursorRect(bounds, cursor: .pointingHand)
        }
    }
    

提交回复
热议问题