On 17/10/2009, at 3:07 AM, Kevin Barnes wrote:

I'm porting an app from Carbon to Cocoa. I notice that when I use the
carbon function PickColor to get a color dialog, the dialog has OK and
Cancel buttons, but when using NSColorPanel the dialog does not have
those buttons. Is there a way to get OK and Cancel buttons in the
Cocoa version of my code?


NSColorPanel is very much a self-contained class that offers little customisation in itself (though you can add custom pickers to it). Its design is quite different from the old modal color picker in Carbon.

Where possible, at those places in your interfaces that you need to pick a colour (e.g. a "Color..." button in a dialog, say), replace those with NSColorWells which will interact with the floating modeless color panel automatically. This will make your app much more standard as a Cocoa app rather than trying to emulate the old way of doing things.

If you really have no option, note that NSColorPanel subclasses NSPanel, so it might be possible to run it modally or as a document modal sheet though I've never tried it so I don't know if it's possible. I see no built-in way to add OK/Cancel buttons but if you can persuade it to run modally in some fashion you'll probably be able to add these programatically to the panel.

--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