I was wondering if it was possible for a Cocoa-Applescript app to receive NSTextDidChangeNotifications? I've looked at the NSNotificationCenter documentation and specifically at the addObserver:selector:name
bject: method but don't see how I could get the parameters for it.
I assume I'd need something like this:
But I'm not even sure it's possible to pass an Applescript function as an observer. And if so is there a syntax I could use for the textDidChange selector? And would I use the following for the name parameter?:
And the object parameter would be the property that I associated with the NSTextField in Interface Builder?
And just in case I'm looking at the problem wrong, I have a "Connect" button that I want to keep disabled until the user has at least typed something into both the username and hostname fields. If I could get the textDidChange notifications for those text fields I could check and see if both fields are not empty and then call connectButton's setEnabled_(true). Is there a better way to go about doing that?
I assume I'd need something like this:
Code:
tell defaultCenter() of current application's NSNotificationCenter
addObserver_selector_name_object_(...)
end tell
But I'm not even sure it's possible to pass an Applescript function as an observer. And if so is there a syntax I could use for the textDidChange selector? And would I use the following for the name parameter?:
Code:
current application's NSTextDidChangeNotification
And just in case I'm looking at the problem wrong, I have a "Connect" button that I want to keep disabled until the user has at least typed something into both the username and hostname fields. If I could get the textDidChange notifications for those text fields I could check and see if both fields are not empty and then call connectButton's setEnabled_(true). Is there a better way to go about doing that?