Page 1 of 1

disable command-q shortcut

Posted: Mon Apr 07, 2008 7:22 pm
by basilico
I first excuse for the mistakes: it is because english is not my mother language.

I need to disable the possibility to use command-q shortcut to quit an application to prevent user doing this.

I tried this code in the stack script and in the card script (app has only one card)

Code: Select all

on commandkeydown theKey
if theKey is "q"
then
answer "You cannot quit this way. Enter the data and click Send." with "OK"
end if
end commandKeydown
but it doesnt work: no dialog box appears and the app quits anyway

If I change the "q" with another character (i.e. "y") the dialog box appears after pressing command - y.

Anyone has suggestions?

Thanks in advance!

Posted: Mon Apr 07, 2008 9:25 pm
by Mark
Hi Basilico,

Try this:

Code: Select all

on shutDownRequest
  answer "You cannot quit this way. Enter the data and click Send." with "OK" 
end shutDownRequest
I wonder whether you might be able to disable the Quit menu item entirely, but I can't find a way to do this.

Best,

Mark

Posted: Tue Apr 08, 2008 7:38 am
by basilico
Hi Mark

your code works fine, but only after saving the stack as standalone.

Before saving as standalone the shutDownRequest code doesnt trap anything and it's still possible to exit the app using the command-q shortcut.

I've tried the code on a Mac, i still must try it on Windows to see if it works fine too.

Many Thanks !!!