Bindings alert issue
Bindings alert issue
- Subject: Bindings alert issue
- From: "Jim Thomason" <email@hidden>
- Date: Tue, 11 Nov 2008 18:57:01 -0600
Here's a peculiar little case that I hope is easy to resolve.
Here's the case I ran into:
I had bound an NSTextField to an attribute of an object. The interface
at that point implied that the user could update the value in that
field, then immediately click a button to perform an action. The
problem was that the value wasn't updated yet, since the user hadn't
pressed enter. Just clicking the button apparently isn't enough for
the text field to lose focus and commit the changes.
To fix, I rewired to use an NSObjectController that pointed at my
object, and then bound through that instead of directly to the object.
Then, when my save: method was called, I first called
[myObjectController commitEditing] and checked its return value. If it
succeeded, then there were no validation errors and I continued
saving. If it failed, then I bowed out and presented the dialog to the
user to fix. Worked like a charm - either my field was saved or the
user got an error right away.
The problem is that when the button is pressed the error message
displays in a new window, whereas if the user were to hit enter, the
error message displays in a sheet.
I have a simple little test program to illustrate the issue:
http://www.bassetsoftware.com/osx/bindingsfail.zip
Type in any value to the field. If you type in "Microsoft", it fails
with a validation error. If you type it in and hit Return, the error
displays in a sheet. If you type it in and hit the "Save changes"
button, it displays in a window. It's as if the object controller no
longer knows what window it's associated with, so the sheet displays
as a window instead.
Is there anything I can do differently to get my error to display in a
sheet? Because if there isn't something else I can do, I'm going to
consider this a bug and file a report.
Thanks,
-Jim.....
_______________________________________________
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