Question

Is there any way I could dim my NSWindow (basically putting a black transparent layer over top of it that you cannot click through) and then layer a custom NSView on top?

Was it helpful?

Solution

You could create an additional NSView which contains your custom NSView. This new NSView would simply draw the black transparent layer in its drawRect and capture all events to avoid them being passed through to the window.

OTHER TIPS

A more compartmentalized way would be to make a borderless window containing the black view and the custom NSView, and make that a child window of the window you want to “dim”. Then use NSViewAnimation to fade the window in and out.

You will, of course, need to handle keeping their sizes matched if the “dimmed” window is resizable.

You could just set the background color of your NSWindow the black and change the opacity to your liking.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top