I am making this simple ApplescriptObjC cocoa app just as an exercise for me to understand the multi treading, it is a text field and a label, I was trying to update the label in real time while typing in the text field, but it only get updated once I press enter but not in real time, any idea how I can make that work? here is the code. Thanks
script AppDelegate
property parent : class "NSObject"
property prgLabel: missing value
property subjectFeild: missing value
on applicationWillFinishLaunching_(aNotification)
-- Insert code here to initialize your application before any files are opened
activate
end applicationWillFinishLaunching_
on applicationShouldTerminate_(sender)
-- Insert code here to do any housekeeping before your application quits
return current application's NSTerminateNow
end applicationShouldTerminate_
on textChange_(sender)
set SU to subjectFeild's stringValue() as string
prgLabel's setStringValue_(SU)
end textChange_
end script
1) Set the delegate of the textfield to be your app delegate.
2) Implement controlTextDidChange, which is called every time the text field changes during editing.
script AppDelegate
property parent : class "NSObject"
-- IBOutlets
property theWindow : missing value
property prgLabel: missing value
property subjectFeild: missing value
on applicationWillFinishLaunching:aNotification
subjectFeild's setDelegate:me
end applicationWillFinishLaunching_
on controlTextDidChange:notification
prgLabel's setStringValue:subjectFeild's stringValue()
end
end script