Hello, I'm starting working with Core Animation and I started wondering how to handle various kinds of mouse events like
- mouse entered a
CALayer
- mouse exited a
CALayer
- mouse click on a
CALayer
For now I'm concentrating just on mouseDown
message sent to my custom view. According to the documentation I should use -hitTest:(CGPoint)point
calling on my root layer (the one set with [customView setLayer:rootLayer]
).
It should return the farthest layer in the tree that is in position specified by point. So I did:
[rootLayer hitTest:[event locationInWindow]]
but it doens't work. It seems to work if I just click on rootLayer
, otherwise it returns just null
. Of course sublayers are added to rootLayer (infact they are drawn)
Am I missing some kind of coordinate conversion? Apart from that, is it the way to handle mouse clicks?
To find whenever mouse enters a CALayer do I have to keep hit testing for every movement update of the mouse?
Thanks in advance