NSValueTransformer problem with NSTextField update
NSValueTransformer problem with NSTextField update
- Subject: NSValueTransformer problem with NSTextField update
- From: Paul Bruneau <email@hidden>
- Date: Thu, 17 Sep 2009 14:15:27 -0400
Greetings-
I have written a subclass of NSValueTransformer which converts an
NSString from something like "1-1/2" to an NSNumber with a value of 48
for my model to store (converts inches and fractions to number of
32nds). It also does the reverse transformation.
This is working perfectly for columns in an NSTableView that I have
bound to NSInteger properties in a model object. If I enter: 1 1/2 and
press return, it will store the correct number, and it will even
instantly update the cell to contain the "cleaned up" version of the
fraction which would be: 1-1/2" (which I find very desirable). So it's
like the the transformer is working in the normal direction to store
the correct value, then the reverse transformer is also getting called
and updating the text cell.
So then I had need to use this transformer for a few NSTextFields on
the same window as the table and here is the weirdness:
When I enter the text (say 1 1/2) and press return, the correct value
is getting set in model BUT the field content is not getting updated
like it does in the NSTableView. It will select the text, but it will
not replace it with its "cleaned up" content which should be: 1-1/2"
If I choose Undo (and also Redo), then the "cleaned up" text appears.
Or if I close the window, and then re-open it, then the "cleaned up"
text is correctly displayed (ditto for the document).
Does anyone have any idea why I am seeing this difference between the
table columns and the text fields?
Is it normal for a transformer to do that nice "clean up" after return
is hit that I am seeing in my table, or is that being caused by some
lucky accident in my case?
Thank you
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden