I have a simple one-column NSTableView full of text. When I add very long lines to it, the text that doesn't fit into the column gets cut off and replaced by "...". I don't want that. Instead, I want to have a horizontal scrollbar that allows the user to view the complete list entry.
Sounds simple enough but turns out to be much more complicated than I thought. To my surprise, there doesn't seem to be any way to just tell the NSTableColumn to be as wide as its largest entry. So I had the idea of just keeping track of the widest entry and updating the NSTableColumn whenever a wider entry is inserted. To do that, on insertion of a new entry, I'm calculating entry lengths like this: NSCell *cell = [tableView preparedCellAtColumn:0 row:idx]; NSSize size = [cell cellSize]; Then I compare it against the previously widest entry and update the NSTableColumn width if necessary, like so: if(size.width > widestWidth) { [tableColumn setWidth:size.width]; widestWidth = size.width; } However, this still isn't perfect because the last two characters of the widest entry are still cut off and replaced by "...". Of course, I can solve this by just adding something a few points to size.width but of course I don't want that because I'm looking for a solution that works with all UI fonts and sizes so hard-coding a certain point value that is added to size.width is definitely a no-go... Any hints on how to proceed from here? Thanks! -- Best regards, Andreas Falkenhahn mailto:andr...@falkenhahn.com _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com