7

On OSX have a custom transparent window, with a NSView inside of it that manages OpenGL drawing:

public class MyCustomOpenGLView : NSView
{
    NSOpenGLContext openGLContext;
    // ...
}

I have set the following (using Xamarin):

openGLContext.SurfaceOpaque = false;

Which is equivalent to:

GLint opaque = 0;
[[[wnd contentView] openGLContext] setValues:&opaque forParameter:NSOpenGLCPSurfaceOpacity];

I have also set the "Opaque" property on the NSView that manages OpenGL to false:

    public override bool IsOpaque
    {
        get
        {
            return false;
        }
    }

Which is equivalent to:

@implementation NSOpenGLView (Opaque)
-(BOOL)isOpaque {
    return NO;
}
@end

Then during the rendering I set the clear color to transparent:

GL.ClearColor(Color.Transparent);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
// Draw shape here...

The view renders the shape with a transparent background but I can still click on the transparent areas. I want to be able to click through the transparent areas.

I tried overriding the HitTest method and the NSView is indeed catching my mouse clicks on the transparent areas. What am I doing wrong here? Any help would be much appreciated!

Bob
  • 821
  • 1
  • 17
  • 36
  • Have you already tried [this](http://stackoverflow.com/questions/5357447/click-through-nsview)? – BDL Jul 03 '16 at 21:33
  • @BDL I only have a single view inside of a Window. That answer has to do with multiple subviews. – Bob Jul 03 '16 at 22:25
  • @Bob Since you only have a single view, when you say you want " click through the transparent areas", what do you want to happen with the "click"? – SushiHangover Jul 10 '16 at 00:37
  • @SushiHangover I want the click to go through the window on transparent areas as though it isn't even there. So if I had a chrome window open behind my window, and I clicked a transparent area it would click the chrome window. – Bob Jul 10 '16 at 22:40
  • @Bob I think you may want to look at multiple/layered UIViews as iOS only expects one UIWindow and touches/hit-testing only considers the top windows and does not "go through" multiple windows. This is written up in the iOS docs... – SushiHangover Jul 11 '16 at 00:56
  • @SushiHangover do the iOS docs apply to OSX? Maybe I was unclear in my question but this is on mac. – Bob Jul 11 '16 at 01:10

0 Answers0