2016-08-10 7 views
0

私はこの単純なApplescriptObjCココアアプリを、マルチトレッドを理解するための練習と同じように作っています。それはテキストフィールドとラベルで、私はリアルタイムでラベルを更新しようとしていましたテキストフィールドですが、入力を押しただけでは更新されますが、リアルタイムではありません。どのようにしてその作業を行うことができますか?ここにコードがあります。 おかげapplescriptobjcでGDCを実装する

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

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 
関連する問題