Re: Core Animation layer-backed NSViews and mouse handling
Re: Core Animation layer-backed NSViews and mouse handling
- Subject: Re: Core Animation layer-backed NSViews and mouse handling
- From: Bill Dudney <email@hidden>
- Date: Wed, 9 Apr 2008 06:51:39 -0600
Hi Matt,
I hope what Scott said made sense (and what I said in the book, thanks
BTW to Mike for the plug).
If you have a layer backed view (i.e. you only call
myButton.wantsLayer = YES) then you should not ever touch the layer,
only use the methods that are exposed through the view and its animator.
So if you are going to move a button, just move the button, don't
touch the layer. My guess is that when you move the layer it moves but
the view does not and that is why you are seeing the representation of
the button move but you are not actually able to click it.
Hopefully that answers the why, now on to the how to fix it...
A couple of things;
- if you only want to animate the moving or rotating of the button
call the animator
- if you don't need to rotate then you don't even need layer backing
In other words move the button like this;
[[myButton animator] setFrameOrigin:newLocation];
this line of code will cause the button (the whole thing,
representation and view) to move to newLocation. You don't need layers
in the picture for this to work.
If you want to rotate the button and have things work properly you
need something like this.
myButton.superview.wantsLayer = YES; // this will cause superview and
all subviews to be layer backed
[[myButton animator] setFrameCenterRotation:myAngle];
HTH,
-bd-
http://bill.dudney.net/roller/objc
On Apr 8, 2008, at 10:55 AM, Matt Long wrote:
Hey Mani,
I never solved the problem completely, however, I realized that what
you need to do, or so it seems, is to somehow get notified when the
animation has finished and then actually move the button to the
position where the animation stopped. It seems really convoluted to
me, but I can't find any further documentation as to why when you
move the button you see it change, but clicking the button at its
new location no longer works. You have to click in the original spot.
Maybe someone else can shed some light on the why.
-Matt
On Apr 8, 2008, at 6:30 AM, Manfred Schwind wrote:
Hi,
I have a layer-backed NSView, say an NSButton (or a complete view
hierarchy with many controls), and I am transforming - moving,
rotating, etc. - its layer around. Now when I try to click the
NSButton at its currently "visible" position, drawn by the CALayer,
it does not work. I have to click into the area where the NSButton
originally was, before transforming its layer.
Is there an easy way to get this working as expected? Without re-
implementing the whole mouse handling of all affected views by
myself?
I know that the mouse handling works when rotating a button with
setFrameRotation, so Cocoa may internally be prepared for this kind
situation. Would be really great if this would also work for
general transformations done by CALayers.
Regards,
Mani
--
http://www.mani.de
iVolume - Loudness adjustment for iTunes.
LittleSecrets - The encrypted notepad.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden