NSFormatter, bindings & control:didFailToFormatString:
NSFormatter, bindings & control:didFailToFormatString:
- Subject: NSFormatter, bindings & control:didFailToFormatString:
- From: John Bishop <email@hidden>
- Date: Wed, 12 Oct 2005 08:58:34 -0500
In 10.3, a custom NSNumberFormatter works just great for detecting entry
errors in an NSTextField (in -getObjectValue:forString:errorDescription:)
which are nicely handled (with an appropriate alert, sheet or beep) by the
NSTextField's delegate in -control:didFailToFormatString:errorDescription:.
Life is good.
When the NSTextField is subsequently set up with a binding on its value, Cocoa
imposes it's own strategy (a modal alert) on dealing with the formatting
failure by putting up its own alert (with a terse "Alert" message, the error
string from the formatter and a "Discard Changes" button) IN ADDITION TO AND
IN CONFLICT WITH the carefully crafted sheet or alert of my own construction.
How do I stop this extra alert but still bind the value of the NSTextField?
I've tried intercepting in the delegate with -control:isValidObject: and
-control:textShouldEndEditing: to no avail. I've tried implementing the
-validate<Key>:error: method for the binding, but it's not called (and the doc
says it won't be called). Surely the answer can't be that bound controls
can't use a formatter.
Here's part of the reverse stack trace to the extra alert:
NSRunAlertPanel
NSBinder presentAlertWithError:fallbackMessage:
allowDiscardEditing:relatedToBinding:
NSValueBinder handleValidationError:description:
inEditor:errorUserInterfaceHandled:
_NSBindingAdaptor _handleValidationError:description:
inEditor:errorUserInterfaceHandled:bindingAdaptor:
_NSBindingAdaptor handleValidationError:description:
inEditor:errorUserInterfaceHandled:
NSActionCell _validateEntryString:uiHandled:
Thanks.
John
------------------------------------------------------------------
John Bishop <mailto:email@hidden>
Mulligan Software <http://www.mulligansoftware.com>
Mulligan's Golf Personal - Stats & Handicapping for the Mac Golfer
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden