- (void)mouseDown:(NSEvent *)theEvent { NSPoint mousePoint = [theEvent locationInWindow]; //NSPoint localPoint = [self convertPoint:mousePoint fromView:nil]; CALayer *hitLayer = [[self layer] hitTest:mousePoint]; NSLog(@"MainView, hitLayer: %@", hitLayer.name); NSLog(@"mousePoint %f %f", mousePoint.x, mousePoint.y); }
533Getting Mouse Position in NSWindow
47Specifing Values in CALayer
You can not specify a structure field key path using Objective-C 2.0 properties. This will not work:
myLayer.transform.rotation.x=0;
Instead you must use setValue:forKeyPath: or valueForKeyPath: as shown below:
[myLayer setValue:[NSNumber numberWithInt:0] forKeyPath:@"transform.rotation.x"];
brrrrrr.
- (id)valueForKey:(NSString *)key
- (void)setValue:(id)value forKey:(NSString *)key
…
NSKeyValueCoding Protocol Reference