Re: Trouble with NSButtonCell
Re: Trouble with NSButtonCell
- Subject: Re: Trouble with NSButtonCell
- From: Corbin Dunn <email@hidden>
- Date: Thu, 03 Sep 2009 08:40:42 -0700
On Sep 3, 2009, at 7:58 AM, Scott Andrew wrote:
I think you need to create a subclass of NSButton that uses your
cell. Then use setAction and setDoubleAction.
Creating a subclass of NSButton isn't necessary; the custom cell can
be set in IB (Leopard+).
Dave needs to subclass NSButtonCell and provide a custom
trackMouse:inRect:ofView:untilMouseUp:, since the superclass will
always call the -action, even for a doubleclick, and there is no way
to prevent that.
An optional "easy hack", might be to look at [NSApp currentEvent]'s
clickCount (first making sure it is a mouse event). You could do this
in the action itself. If it is a double click, then do something
different. If it is a single click, make sure it is where you want it
to be (hit test the event location) before doing the work you want.
A subclass is more reusable and the best approach, but probably more
work.
corbin
_______________________________________________
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