用 applescriptobjc 实现 GDC
implementing GDC with applescriptobjc
我正在制作这个简单的 ApplescriptObjC cocoa 应用程序作为我理解多线程的练习,它是一个文本字段和一个标签,我试图在打字时实时更新标签在文本字段中,但只有在我按下回车键后它才会更新,但不是实时更新,知道我如何才能做到这一点吗?这是代码。
谢谢
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) 将文本字段的委托设置为您的应用委托。
2) 实现 controlTextDidChange,在编辑过程中每次文本字段发生变化时都会调用它。
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
我正在制作这个简单的 ApplescriptObjC cocoa 应用程序作为我理解多线程的练习,它是一个文本字段和一个标签,我试图在打字时实时更新标签在文本字段中,但只有在我按下回车键后它才会更新,但不是实时更新,知道我如何才能做到这一点吗?这是代码。 谢谢
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) 将文本字段的委托设置为您的应用委托。
2) 实现 controlTextDidChange,在编辑过程中每次文本字段发生变化时都会调用它。
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