disable command-q shortcut

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
basilico
Posts: 2
Joined: Mon Apr 07, 2008 2:53 pm

disable command-q shortcut

Post by basilico » Mon Apr 07, 2008 7:22 pm

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!

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Mon Apr 07, 2008 9:25 pm

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

basilico
Posts: 2
Joined: Mon Apr 07, 2008 2:53 pm

Post by basilico » Tue Apr 08, 2008 7:38 am

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 !!!

Post Reply