I’m still struggling with the View-Based NSOutlineViews introduced with OSX Lion. While everything works quite good now, I’d like to add Mail.app-like unread badges to rows.
Is there a better way for View-Based NSOutlineViews than following the example of -(void)drawBadgeForRow:(NSInteger)rowIndex inRect:(NSRect)badgeFrame in PXSourcelist ?
Thanks, Bucks
In case anybody encounters the same problem, I’ve found a solution in the Lion release notes that is actually quite simple.
First subclass
NSTableCellView, add anIBOutletfor anNSButtonand a@synthesize/@propertystatement to it. Then open theNSTableCellViewthat should have a badge in Interface Builder. Set it’s class to your newly created subclass and add a button to it. Set the button style to"inline"and it’s type to"switch".Now select the
NSTableCellViewagain and connect theNSButtonIBOutletto your added button.That’s it. You can now call e.g.
[[cellView button] setTitle@"123"]]to set the rows badge label to123or any arbitrary string.