On 19 Feb 2009, at 11:45 am, Walker Argendeli wrote:

'm just having a bit of trouble getting this to work. First off, I wasn't 100% certain about which should be buttonCell and which should be self, although I think I got all of that right. how does startTrackingAt:startPoint:inView: get called, however?

Again, sorry for my ignorance, but I'm just getting started with Cocoa.

Thanks for your help, and the code!



I'm not quite sure what you've done here. What's the outlet 'buttonCell' refer to? This *IS* the button cell, it doesn't need to refer to another one. I'd get rid of that and replace all uses of it with 'self', as per the original code.

Note that you're not subclassing the button here, you are subclassing its cell. Your class name maybe ought to reflect that as it currently suggests that it's a subclass of a button, even though clearly it isn't.


In IB, let's say you've dragged a button into your window. To customise the cell class, drill down into the button (keep clicking it) until the cell is selected (keep an eye on the inspector palette so you know when this is). Then in the 'Identity' (i symbol) section of the inspector palette, enter the name of your custom class in the field marked 'Class'. That should be all you need to do to make the button use your custom cell subclass.

Don't forget to:

a) include the code in your project, and
b) hook up a menu to the cell so that it does have something to pop up.

You also need to set the 'showsMenuAfterDelay' to YES somewhere. It'll default to NO unless you set it, so you might also want to add an - awakeFromNib method to your code and set this to YES there.

-startTrackingAt:startPoint:inView: gets called when the mouse is clicked in the button. This is a method of the normal NSButtonCell that is being overridden here.



--Graham


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to