Bindings and Validation
Bindings and Validation
- Subject: Bindings and Validation
- From: Philip Buckley <email@hidden>
- Date: Thu, 04 Apr 2013 12:40:24 +0100
If, for example, I have a list of names, I can put them in an array and show them in a table view by binding through an array controller. Then if, say, i want the user to be able to edit the list, they can edit the names in the table view itself, or I can show a selected name in a text field below the table view (binding to selection). But what if I need to enforce certain restrictions on what the user enters, for instance that they can't enter a name that is already in the list (i.e. the names need to be unique)?
There is a section in the documentation about validation <http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/KeyValueCoding/Articles/Validation.html>, but I have hadn't had an real success translating it to AppleScriptObjC (it may be that I simply haven't understood how it is supposed to work in Cocoa in the first place).
I can get around the problem by something like . . . showing the names in a table view with an edit button. When the user clicks on the edit button I can get the selection from the array controller, establish what the current name is, show that name in a text field on a panel which I show to the user. When the user clicks the OK button to dismiss the panel I can check whether the entered name is valid before dismissing or otherwise the panel. When the panel is dismissed with a valid name I can put the new name back into the list by removing the currently selected name and inserting the newly entered name in its place via the array controller.
This works ok but as an interface it just seems a bit cumbersome. I don't really like throwing up panels all the time to get user input - it would make for a more pleasant user experience if the user simply edited the list in the window where the names are displayed . . . and there are plenty of bindings examples that show this . . . but none (that I have been able to find) which include validation of what the user enters.
Any thoughts?
Philip
_______________________________________________
Do not post admin requests to the list. They will be ignored.
applescriptobjc-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden