I have a problem using text did change: I can’t get NSNotification center to tell my script a text field was changed.
I already have this subroutine:
on controlTextDidChange_(aNotification)
set theObject to aNotification's object
if theObject = SerialKey then
set SerialkeyValue to SerialKey's stringValue
display dialog SerialkeyValue
end
end controlTextDidChange_
I also added the property and NSNotificationCenter’s defaultCenter()'s addObserver_(“textDidChange:”) to applicationwillfinishlauching.
But i’m still getting nothing from NSNotification center.
I can say that I only used notification center only once before and only got it to work with really much help from DJ Wazzie Bazzie.
If you are unsure about delegates --and delegate protocols-- , there is a good video on Shane Stanley’s site, “demonstrating the connection of application interface elements to their corresponding AppleScript function code using Interface Builder outlets and actions”.
In IB, you click on your text field to get it selected, then, maintaining the CTRL key pressed, you drag your text field to the app delegate blue cube, and in the hub window which appears, you choose “delegate”.
This makes your main script the delegate of the text field, and from now the notifications sent by the text field will be received by your main script – that is, your controlTextDidChange_ handler will be called.
Not evident at the beginning, but you will certainly master it and then use and abuse from the binding mechanism