I'm using an NSBrowser (10.6SDK/Cocoa app) and I want to send a message to a browser column that will make it resize its width to match the width of the largest cell within that column.
Seems pretty basic in concept, even as though there should be a method for it, but no.
Anyone here tackle this before? How did you solve it? Code sample?
// Update I've added drop-support. The code works, but the new item in the column doesn't fit (has an ellipse).
-(BOOL) browser:(NSBrowser *)browser acceptDrop:(id <NSDraggingInfo>)info atRow:(NSInteger)row column:(NSInteger)column dropOperation:(NSBrowserDropOperation)dropOperation
{
NSPasteboard* pboard = [info draggingPasteboard];
NSData* rowData = [pboard dataForType:CMCourseDataType];
NSIndexSet* rowIndexes = [NSKeyedUnarchiver unarchiveObjectWithData:rowData];
NSArray *selectedCourses = [[self coursesArrayController] selectedObjects];
Group *selectedGroup = [[self allGroupsArray] objectAtIndex:row];
[selectedGroup addCourses:[NSSet setWithArray:selectedCourses]];
[browser reloadColumn:1];
/* new code tried below, to cause column 1 to resize its width but they have no affect */
[browser sizeToFit];
[[browser matrixInColumn:1] sizeToCells];
In awakeFromNib, I set:
[browser setColumnResizingType:NSBrowserUserColumnResizing];
thanks