Can anybody point me to some good tutorials/guides for implementing custom controls?

I've been reading the Cocoa Event Handling Guide, The reference and accompanying conceptual guides for NSControl, NSCell, NSActionCell and NSView, but I'm more confused than when I started.

If anyone could answer these more specific questions or point me to good reference material I'd really appreciate it:

1. How does one setup the target/action mechanism for a custom control, i.e. client code can call setAction: and setTarget: and have these stored in the class? Does this come for free when you subclass NSActionCell? Or is it more correct to implement these methods yourself, in an NSView subclass? Or NSControl subclass?

2. Is wrapping existing controls in a custom control class a good idea? I.e. the custom control class is a container for a handful of standard controls, configures them in an appropriate way, and presents an interface to client code as if it were a single control, i.e. a target-action mechanism, and public properties for querying the state of the control?

My (current) higher level goal is implementing a control that includes 3 momentary buttons, the middle button showing a menu when pressed. These buttons all edit one piece of data, a ratio. This control needs to be invoked (i.e. added to parent view) from code and be reusable. The client code needs to be informed when a button is clicked and be able to query the control's current value. The new control is responsible for the appearance, and the contents of the menu. In future I will also need to implement more complex custom controls/ views, that include custom drawing and a handful of subcontrols (that are all related and present a unified interface to client code).

I've noticed that NSSegmentedControl can implement pretty much all of the control, so I think I want to use that internally, implementing all the config for the segmented control, and mapping the actions of the individual buttons to set the data in the control and invoke the custom action (that the client code, the target receives).

Is there a way to achieve this? Am I barking up the wrong tree?

thanks
Rua HM.
_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to