Re: No validation with a bound NSTableView and custom NSFormatter
Re: No validation with a bound NSTableView and custom NSFormatter
- Subject: Re: No validation with a bound NSTableView and custom NSFormatter
- From: Ben Kennedy <email@hidden>
- Date: Tue, 01 May 2012 20:09:27 -0700
On 01 May 2012, at 7:42 pm, Quincey Morris wrote:
> 3. That protocol has a method 'control:isValidObject:'.
>
>> "This method gives the delegate the opportunity to validate the contents of the control’s cell (or selected cell).
>
> That seems like what you want, if you query the formatter directly from this delegate method.
I hadn't noticed that one before. However, for some reason, it does not get called on my delegate.
> Whether NSTableView has an automated mechanism for querying the formatter itself, I don't know, and I can't find any documentation that suggests it might.
Well, the NSControlTextEditingDelegate protocol also provides 'control:didFailToFormatString:errorDescription:', which seems to be to the point of what I want:
> Invoked when the formatter for the cell belonging to the specified control cannot convert a string to an underlying object.
>
> Return Value: YES if the value in the string parameter should be accepted as is; otherwise, NO if the value in the parameter should be rejected.
And unlike control:isValidObject:, it does get called on my delegate. Unfortunately, my return value of NO seems to be ignored.
The thing about all this is that a few revs back, when I was using a dumb array with NSTableViewDataSource and no bindings, I was getting the validation behaviour for free. Now it's gone. I guess I should re-trace my steps and try to figure out what subtle critical difference I've introduced.
cheers,
b
--
Ben Kennedy, chief magician
Zygoat Creative Technical Services
http://www.zygoat.ca
_______________________________________________
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