Clicking through NSWindow/CALayer
NickName:Josh Buchacher Ask DateTime:2012-05-25T12:10:23

Clicking through NSWindow/CALayer

So I'm working on an issue I have when trying to do some simple animation using CAKeyframeAnimation, and I believe my problem is more related to not fully understanding how NSWindow, NSView, and CALayer work together.  I have two main objects in question. MyContainerWindow (NSWindow subclass) and MyMovableView (NSView subclass). My goal is to be able to animate MyMovableView back and forth across the screen, while maintaining the ability to click on anything through MyContainerWindow unless you are clicking on wherever MyMovableView is. I am able to accomplish the first part fine, by calling -addAnimation:forKeyPath: on myMovableView.layer, and everything is great except I can't click through MyContainerWindow. I could make the window smaller, but then the animation would clip by the bounds of the window.

Important points:  1) MyContainerWindow is initWithFrame to [[NSScreen mainScreen] frame], NSBorderlessWindowMask, defer no, buffered 2) I setWantsLayer:TRUE to MyMovableView 3) MyContainerWindow is clear, and I want it to be as if there wasnt a window at all, but need it so I have a larger canvas to animate on.

Is there something obvious I'm missing to be able to click through an NSWindow?

Thanks in advance!

Copyright Notice:Content Author:「Josh Buchacher」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/10748364/clicking-through-nswindow-calayer

More about “Clicking through NSWindow/CALayer” related questions

Clicking through NSWindow/CALayer

So I'm working on an issue I have when trying to do some simple animation using CAKeyframeAnimation, and I believe my problem is more related to not fully understanding how NSWindow, NSView, and CA...

Show Detail

Is it possible to display a NSWindow on a CALayer?

I'm provided with a CALayer* and would like to know if it's possible to dynamically create a NSWindow and show it on the layer? Thanks in advance!

Show Detail

How to achieve mouse click-through on NSView with CALayer?

I have a custom borderless NSWindow in the shape of a circle. To do this I use a custom NSView that draws a filled circle. Mouse clicks on a transparent pixel inside the window's content rect go

Show Detail

CALayer not showing

In trying to make a draggable sort of CALayer ( Question on Stack Overflow here ) I tried creating a window through code and adding a CALayer to it, but I don't get why it's not showing. NSRect re...

Show Detail

Open an NSWindow by clicking NSRect in cocoa

In my program I am able to determine whether a mouseclick was made within a certain NSRect. How can I open a new NSWindow by clicking this NSRect?

Show Detail

Opaque NSWindow and WindowServer poor performance

I need to create non-opaque transparent window, with opaque subviews (call them surfaceView) inside. Each subview can contain thousands of subview (call them controlView). So structure must be some...

Show Detail

Click through custom NSWindow

I have custom NSWindow with custom NSView set as its contentView. The window gets initialized with: [window setOpaque:NO]; [window setBackgroundColor: [NSColor clearColor]]; [window setHasShadow:...

Show Detail

How can I close a NSWindow loaded modally as popup, by clicking outside of it?

How can I close a NSWindow loaded modally as popup, by clicking outside of it? I would like to handle the mouse event, when the cursor is outside the modal window with the focus (but still inside ...

Show Detail

NSWindow not showing?

I've the following code : NSRect contentRect = NSZeroRect; contentRect.size = NSMakeSize(400, 400); contentRect.origin = NSMakePoint(400, 400); NSWindow* window = [[NSWindow alloc] initWithConte...

Show Detail

Holes in NSView or NSWindow

IS it possible to cut out parts of a NSWindow or an NSView and make them see through? I have an NSWindow with an NSView and I want to either: A) make a hole in the NSWindow to be able to see thro...

Show Detail