开发者

Display dialog causing error

开发者 https://www.devze.com 2023-03-22 03:42 出处:网络
I have a simple dialog. The user can either accept the dialog or cancel it. But when I cancel, it errors. Why?

I have a simple dialog. The user can either accept the dialog or cancel it. But when I cancel, it errors. Why?

try
    display dialog "I cause an erro开发者_如何学运维r when my 'cancel' button is pressed."
on error error_message number error_number
    display dialog "Error: " & error_number & ":" & error_message & "."
end try


Here's one that doesn't error!

display dialog "I won't cause an error because I specified the buttons myself and didn't include a cancel button!" buttons {"Quit", "OK"} default button 2


The Cancel button always causes an error in the display dialog command. You cannot fix that. However, if you do as @regulus6633 suggested and specify the buttons yourself, you won't have to worry about errors.

0

精彩评论

暂无评论...
验证码 换一张
取 消