Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > NSTextFieldCell (in NSTableView) insists on incorrect formatting. why?

NSTextFieldCell (in NSTableView) insists on incorrect formatting. why?
Thread Tools
Addicted to MacNN
Join Date: Nov 2002
Location: Seattle, WA
Status: Offline
Reply With Quote
Jan 15, 2004, 01:24 AM
 
In my NSTableView, when adding columns I call setDataCell: on them in order to use my NSTextFieldCell subclass. But whenever I do this (even if I setDataCell:NSTextFieldCell with no subclass at all!), the cells insist on truncating their strings so that only whole words are displayed. Like in the normal NSTableView the string "abc def" would be displayed "abc d" and half an e, now it would be "abc ", with no indication that it's a partial string. I also have an NSFormatter in action on these cells, to truncate with a "...", and this can be seen only in the odd situation where my truncated string is still short enough not to trigger this other mysterious formatting. Any idea how I can get my NSTableColumn's cells to behave like the NSTableView default when I set a specific data cell for them?
thanks
     
Addicted to MacNN
Join Date: Nov 2002
Location: Seattle, WA
Status: Offline
Reply With Quote
Jan 16, 2004, 12:03 AM
 
well, I seem to have found the cause, but it has raised a much more difficult question (I think).

it seems the NSCells I was giving my tableColumns (unlike the NSTableView defualt) had setWraps: set to true. Setting this to false restores the correct behavior.

Now the problem: the reason I was doing this in the first place was so I could have edited cells display as large as the text they contain. Well naturally I would want such large cells to wrap. So now I need a way to tell one cell in a tableColumn to wrap, but not have the others do it (it also seems that once you tell a tableColumn's dataCell to wrap, setting it back causes all manner of inconsistency. Some words wrap and others don't in the same string!).

So, is there a way to get around the NStableColumn oddity that all cells really use the same NSCell instance?
     
Addicted to MacNN
Join Date: Nov 2002
Location: Seattle, WA
Status: Offline
Reply With Quote
Jan 17, 2004, 01:15 PM
 
Originally posted by Uncle Skeleton:
it also seems that once you tell a tableColumn's dataCell to wrap, setting it back causes all manner of inconsistency. Some words wrap and others don't in the same string!
well I figured this one out. when I'm done editing and I setWraps:NO again, I also have to setScrollable:YES because the two properties are somehow linked. I still have no idea what setScrollable is supposed to do in the context of NSTableView cells, but it restores the proper behavior.

The only problem was that all other cells in a column are truncated while editing is going on in one of them. I can fix this by setting the above two properties again in the table delegate's willDisplayCell: method, and refrain from doing so if the row and column match the currently edited one (this might only be working because I had already overridden the -editedRow and -editedColumn methods in my tableview so they are a little more agressive).
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:51 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2