使用applescriptobjc实现GDC

时间:2016-08-10 02:57:29

标签: multithreading cocoa applescript-objc

我正在制作这个简单的ApplescriptObjC可可应用程序,只是为了让我理解多行程,它是一个文本字段和标签,我试图在文本字段中输入时实时更新标签,但是一旦我按下输入但不是实时更新它,任何想法我怎么能做到这一点?这是代码。 谢谢

    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 个答案:

答案 0 :(得分:1)

1)将textfield的委托设置为您的app delegate。

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