【发布时间】:2013-08-11 14:30:33
【问题描述】:
我正在使用 Applescript 在 Xcode 上编写 Mac 应用程序。
我做了一个不会永远停止的函数,但我无法停止它。
当我按下位于窗口上的按钮时,它就会启动。
由于此功能不会停止,因此按钮似乎永远被按下。
我必须使用“Command+Option+Escape”强制退出。 (即使您进行此活动,此应用程序也可能不会停止。)
我想在功能启动之前释放按钮,并且我想通过按下另一个按钮来安全地停止此功能。
这是我的例子。要停止这种情况,请按 Xcode 上的“停止”按钮。
property parent : class "NSObject"
property mylabel : missing value
on applicationWillFinishLaunching_(aNotification)
-- Insert code here to initialize your application before any files are opened
end applicationWillFinishLaunching_
on myStartButtonHandler_(sender)
my myForeverFunction()
end myStartButtonHandler_
on myStopButtonHandler_(sender)
--How can I stop "myForeverFunction"?
end myStopButtonHandler_
on myForeverFunction()
set a to 0
repeat 100 times
set a to a+1
mylabel's setStringValue_(a)
delay 1
end repeat
end myForeverFunction
on applicationShouldTerminate_(sender)
-- Insert code here to do any housekeeping before your application quits
return current application's NSTerminateNow
end applicationShouldTerminate_
这是项目文件 --> https://dl.dropboxusercontent.com/u/97497395/test.zip
对不起,我是日本人,英语写得不好。
【问题讨论】:
标签: xcode macos applescript exit