New in Cappuccino 0.9.6 RC2

The second release candidate of Cappuccino 0.9.6 has been announced. The full list of new features and fixes is long but here are some highlights.

Improved Token Field Autocomplete

CPTokenField Autocomplete Menu

The token field control has been overhauled internally. This makes it much easier to subclass it.

Autocomplete is now more similar to Cocoa with an automatically sized menu placed where it’s needed. Keyboard navigation has been extended with ⌘A (Mac) / Ctrl-a to select all tokens and full key bindings support. Represented object support has been fixed and extended and support for the delegate method tokenField:representedObjectForEditingString: has been added.

Button Types

This release introduces every type of Cocoa button into Cappuccino, and fixes CPMomentaryLightButton. Here are 4 of the most commonly used ones:

  1. CPMomentaryLightButton: the normal type of button. When you click it is looks depressed.
  2. CPPushOnPushOffButton: this button can be on or off, like the on/off button on an old TV. It remains down after you click. If you click it again it pops back up.
  3. CPToggleButton: like CPPushOnPushOffButton, this button is sticky, but it doesn’t look depressed. Instead it changes title to its alternate title when on.
  4. CPMomentaryChangeButton: like CPMomentaryLightButton but it doesn’t look depressed and instead shows its alternate title when highlighted.

Button states

This is how you would configure a button:

[momentaryChangeButton setButtonType:CPMomentaryChangeButton];
[momentaryChangeButton setAlternateTitle:@"Changed!"];

CPButtonTest in the Cappuccino source code has more sample code.

Block Enumeration

In Cappuccino 0.9.6 RC1 we added CPArray enumerateObjectsWithOptions:usingBlock: and CPIndexSet enumerateIndexesUsingBlock:.

In RC2 we get the same for CPDictionary. This makes it much quicker to go over all the keys and values of a dictionary:

var aDict = [CPDictionary dictionaryWithJSObject:{a: 1, b: 3, c: "b"}];
[aDict enumerateKeysAndObjectsUsingBlock:function(aKey, anObject)
    {
        CPLog.info("%@: %@", aKey, anObject);
    };
];

// 2012-09-08 01:53:26.042 objj [info]: a: 1
// 2012-09-08 01:53:26.043 objj [info]: b: 3
// 2012-09-08 01:53:26.043 objj [info]: c: b

More Flexible Toolbars

Toolbars without labels are now supported, so you can have a toolbar with only icons. Also toolbars can take on any height and adapt better to the sizes of the items present in it. You could even put a large control in the toolbar, like the double slider in the screenshot below.

Toolbar Tall and Without Labels

As you might imagine this is how to set a toolbar to icon only mode:

[toolbar setDisplayMode:CPToolbarDisplayModeIconOnly];

As always most of the changes are under the hood as we continue to build up to the 1.0 release. Check out the full list of changes for more.

Subscribe Tweet This
Written by Alexander Ljungberg on 2012 Sep 7 .
Tagged .