Toolbar Updates

13 views
Skip to first unread message

Francisco Tolmasky

unread,
Nov 17, 2009, 2:34:50 AM11/17/09
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.

Saikat Chakrabarti

unread,
Nov 17, 2009, 2:58:43 AM11/17/09
to Cappuccino & Objective-J
Nice! One question though:

> 2. Toolbar should size itself to fit the height of all items more
> reliably

Does that mean the toolbar should have a variable height now? I still
see the line in CPToolbar.j (line 679) that sets viewHeight to 53.0
though (but I haven't tried it out to see if something else is
overwriting this).

On Nov 16, 11:34 pm, Francisco Tolmasky <franci...@280north.com>
wrote:

Dunkie

unread,
Nov 17, 2009, 4:59:44 PM11/17/09
to Cappuccino & Objective-J
Not sure if this is related but with the new Atlas framework, I've
noticed the following with the SearchField in a Toolbar.
The pull down menu with recent itmes is now drawn at the top left of
the screen rather then below the SearchField.
Also, command-v no longer pastes in the SearchField. (Right-Click
Paste still works though).

cacaodev

unread,
Nov 17, 2009, 6:46:34 PM11/17/09
to objec...@googlegroups.com
This should be fixed by this commit when merged ( the link in the first comment):

http://github.com/280north/cappuccino/issues#issue/194
Reply all
Reply to author
Forward
0 new messages