Francisco Tolmasky
unread,Nov 17, 2009, 2:34:50 AM11/17/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Cappuccino & Objective-J
Hey guys, just wanted to give you all a quick heads up of the work
that's recently gone into Capp. One of the bigger changes that
recently went in is an almost complete rewrite of toolbars. The
rewrite fixes a lot of bugs:
1. Spacer items are no longer put in the overflow menu
2. Toolbar should size itself to fit the height of all items more
reliably
3. Better calculation of which items should be moved to overflow menu
4. Highlight text when item is clicked
5. Entire space of toolbar item is now clickable, not just the icon
region.
6. setEnabled: actually dims toolbar items and custom views.
7. Support for manual validation, autovalidation coming soon.
With toolbar item validation, you can dim toolbar items that aren't
currently clickable. You can do this on individual items by calling -
validate, or on an entire toolbar by calling -
validateVisibleToolbarItems. The way validation works is the
following:
1. With items in default configurations (no custom view), the item
will check whether its target (either set explicitly or first
responder) responds to the action you set for it. If it doesn't then
the item will be dimmed. So, if you have a toolbar item that calls
copy: on first responder, it will only be clickable when you have a
view selected that responds to copy:. If it does respond to it, it
will also call validateToolbarItem: on the target if it implements it,
allowing the target to add custom behavior to the validation process.
2. If the item has a custom view, it will simply call
validateToolbarItem: on the target (if it has one). if the validation
fails, it will setEnabled:NO on the custom view if it responds to it.
If you want even more custom behavior, you can just subclass
CPToolbarItem.
Now, I'll be working on autovalidation soon, so for now if you want
the toolbar to validate its menu items you have to explicitly call
validateVisibleToolbarItems. The implementation of autovalidate is
trivial, the tricky part is knowing *when* to automatically call it
without hurting performance too much. At the end up the run loop is
one approach, but this means a call every event, so I'll be
investigating further. Of course, no matter what you can always turn
of autovalidation and handle it explicitly yourself.