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.
精彩评论