Validating text field.

I haven’t been able to find any examples of this validating the contents of a text field with an applescript handler. I’m not sure what to bind to. I’d like to validate a text field as a sound name using NSSound.

Thanks.

One example to validate “after” entry: http://macscripter.net/viewtopic.php?id=40662

validation During entry: http://macscripter.net/viewtopic.php?id=40342

Thank you, I saw those but I’m not at the point where I see the whole picture of where I bind the validation handler, etc. This is basically a timer and I can just check the sounds when I start my timer, but I’d like to have a handler check the contents of the check field for a valid sound when I leave the field and I can’t figure out where to make the binding.

for this purpose I recommend to implement the textDidEndEditing delegate method.
It is invoked always when the user presses tab or return.

But isn’t it easier to provide the available sounds in a popup menu ?

Seems like a good idea, but I am just an infant in using ObjC so if you could provide an example of how I would use this method in Applescript, I’d appreciate it. I have been reading and looking for an example but I am not at the point where I can get anywhere.

Perhaps, but NSSound is so good at finding new sounds, I could just put a file in my ~/Library/Sounds and use it. I am just trying different things as a learning exercise.

You make your script a delegate of the text field, and add an on textDidEndEditing_(notif) handler.

But the popup sounds a much better idea to me too…

Found this on Apple’s AppleScriptObjC-dev list. I was using textDidEndEditing_ method, which didn’t work. I’ll try this but I’m sure it will work by the credible source! :slight_smile:

Here is an example project with a popup button displaying all system sounds.
Although it’s an AppleScriptObjC template the controller class is written in ObjC.
It uses bindings for all connections.
Check the checkbox to keep all items in ~/Library/Sounds in sync

SystemSoundTest

Thanks!