On 05/06/2009, at 11:29 AM, Joar Wingfors wrote:


On 4 jun 2009, at 18.10, Graham Cox wrote:

There's a note in the documentation for -validateToolbarItem: that "NSToolbar only calls this method for image items", which might explain it. So what do I need to do to make this work for the segmented control? I've read all the toolbar and validation documentation I can find but I'm none the wiser - nothing so far stands out as the obvious right way to proceed.


I like to back all of my view-type toolbar items by separate view controllers. In this design it is the job of these view controllers to monitor the state of your application that affects their views, and update the enabled / selected state appropriately. Your views, or view controllers, can often times use bindings to achieve this with minimal fuss and overhead. There is no built in support in NSToolbar for managing view controllers for your view-type toolbar items, so you would have to manage that part for yourself.


Thanks a lot - this is working out well so far.

Follow-up question: how can I turn OFF a segment in a segmented control? The situation is this:

The segmented control represents text alignment - left, center, right, justified. Only one can be on at a time normally, but if I select a non-text object that doesn't respond to the alignment settings, I want to disable the control and turn off all the segments. I can disable it alright, but there doesn't seem to be a way to turn all segments off - passing -1 to selectSegmentWithTag: doesn't do anything, - setSelectedSegment: with -1 produces an out of range exception, even though its counterpart -selectedSegment, returns -1 for no selection.

Any ideas?

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