keyboard shortcut command+q quit during Display Dialog

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?

Thanks for your help

Hi,

this is normal.
You can’t interrupt the display dialog box,
but there is a “giving up” parameter to close it automatically after a certain time

If the default Cancel (or Quit) button is set to 1 - then the enter or return key will quit the script

display dialog "Hello" buttons {"Cancel", "Do Something"} default button 1
display dialog "Do what?" default button 1

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

I don’t get the problem either…
Command period (.) will cancel the script too.

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 hope this helps clarify.

Thanks

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)

Hello

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 :wink:

Yvan KOENIG (from FRANCE mardi 13 mars 2007 11:40:30)

I agree, but i want it to operate like an application more than a dialog

Yes, but it is a dialog. The behavior, you want, is not possible with plain vanilla AppleScript,
but with AppleScript Studio

ok that’s what I needed to hear, thanks stefank. Maybe I’ll look into ASS

I thought, this was already clear in my first post :wink: