How to make a transparent NSView subclass handle mouse events?

后端 未结 7 1603
清歌不尽
清歌不尽 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条回答
  •  猫巷女王i
    2021-02-04 11:15

    George : you mentioned that you tried filling portions with an almost but not quite transparent color. In my testing, it only seems to work if the alpha value is above 0.05, so you might have some luck with something like this:

    [[NSColor colorWithCalibratedRed:0.01 green:0.01 blue:0.01 alpha:0.05] set];
    

    It's an ugly kludge, but it might work well enough to avoid using an event tap.

提交回复
热议问题