I have a applescript application that basically relies on display dialog, but while that is running and expecting a response the menu item for Quit and the key sequence command-q doesn’t work.
Is there any way to interrupt a display dialog with such a keyboard sequence?
That won’t work, is there some other form of user input that WOULD be interruptable like that?
My Code so far is as follows:
set usrInput to (display dialog "Insert text to translate:" with title "ROT13 Translator" default answer "" buttons {"Quit", "Translate"} default button 2 cancel button 1)
repeat while button returned of usrInput is not "Quit"
set textInput to text returned of usrInput
set rot13Text to ""
repeat with char in textInput
set askeeInput to ASCII number char --A-Z = 65-90; a-z = 97-122
if askeeInput is greater than 64 and askeeInput is less than 91 then
set askeeInput to askeeInput + 13
if askeeInput is greater than 90 then
set askeeInput to askeeInput - 26
end if
end if
if askeeInput is greater than 96 and askeeInput is less than 123 then
set askeeInput to askeeInput + 13
if askeeInput is greater than 122 then
set askeeInput to askeeInput - 26
end if
end if
set rot13Text to rot13Text & (ASCII character askeeInput)
end repeat
set usrInput to (display dialog "Insert text to translate:" with title "ROT13 Translator" default answer rot13Text buttons {"Quit", "Translate"} default button 2 cancel button 1)
end repeat
hm, I don’t get the problem,
pressing the “Cancel” button aborts the script in every case.
this behaves in the same way as your script
set rot13Text to ""
repeat
set usrInput to (display dialog "Insert text to translate:" with title "ROT13 Translator" default answer rot13Text buttons {"Quit", "Translate"} default button 2 cancel button 1)
set textInput to text returned of usrInput
set rot13Text to ""
repeat with char in textInput
...
...
set rot13Text to rot13Text & (ASCII character askeeInput)
end repeat
end repeat
Hey, Thanks guys. Yes cmd-. does work, but the problem is, that cmd-q doesn’t; and that’s what most people would expect from an application. I don’t know about you, but when I’m done useing an app I don’t press cmd-[period] but rather cmd-q.
I have confidence in the users to press a “Quit” Button if there is one ;).
As written before, no chance to interrupt a display dialog window (exept ESC, cmd period, or the defined shortcut for the Cancel button)
As far as I know, it’s good practice to match the GUI standards.
Since the first appearance of Apple’s GUI, the shortcuts used to cancel a dialog are ESC and Cmd + .
They are those which every “normal” user expect for such a task.
Even the well known Finder (in its standard setting) doesn’t quit if someone press cmd + Q
Yvan KOENIG (from FRANCE mardi 13 mars 2007 11:40:30)