How to make a transparent NSView subclass handle mouse events?

后端 未结 7 1582
清歌不尽
清歌不尽 2021-02-04 10:31

The problem

I have a transparent NSView on a transparent NSWindow. The view\'s drawRect: method draws some content (NSIma

7条回答
  •  别跟我提以往
    2021-02-04 10:51

    As far as I know, click events to transparent portions of windows aren't delivered to your application at all, so none of the normal event-chain overrides (i.e -hitTest:, -sendEvent:, etc) will work. The only way I can think of off the top of my head is to use Quartz Event Taps to capture all mouse clicks and then figure out if they're over a transparent area of your window manually. That, frankly, sounds like a huge PITA for not much gain.

提交回复
热议问题