2016-08-10 4 views
0

Я делаю это простое приложение для какао ApplescriptObjC так же, как упражнение для меня, чтобы понять, как много стирать, это текстовое поле и ярлык, я пытался обновить ярлык в режиме реального времени, набрав текстовое поле, но оно обновляется только после нажатия кнопки ввода, но не в режиме реального времени, какой-либо идеи, как я могу сделать эту работу? вот код. Благодаряреализация GDC с 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

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 
Смежные вопросы