[comp.sys.mac.hypercard] disabling command-q

jk4i+@andrew.cmu.edu (John McCall Kingsley, III) (12/06/89)

Hello.

I am trying to figure out a way that I can diable the user from using
command-q and closing the stack, in my application the user must quit
using one of my quit buttons, otherwise the databases get messed up, so
is there anyway to trap the command-q and return to the card that you
were on at the time of the command-q

Thanks

Jack Kingsley

dlugose@uncecs.edu (Dan Dlugose) (12/07/89)

In article <EZTGqLG00WB5Q382YJ@andrew.cmu.edu> jk4i+@andrew.cmu.edu (John McCall Kingsley, III) writes:
>
>is there anyway to trap the command-q and return to the card that you
>were on at the time of the command-q

on domenu x
   global readytoquit
   if (x is not "quit hypercard") or (readytoquit is true) then 
       pass domenu
   end if
end domenu

on mouseup -- button to handle quitting
   global readytoquit
   -- do preparations
   put true into readytoquit
   domenu "quit hypercard"
end mouseup

Dan Dlugose
UNC Educational Computing Service

jdevoto@Apple.COM (Jeanne A. E. DeVoto) (12/07/89)

In article <EZTGqLG00WB5Q382YJ@andrew.cmu.edu> jk4i+@andrew.cmu.edu
(John McCall Kingsley, III) writes:
>I am trying to figure out a way that I can diable the user from using
>command-q and closing the stack, in my application the user must quit
>using one of my quit buttons, otherwise the databases get messed up, so
>is there anyway to trap the command-q and return to the card that you
>were on at the time of the command-q

To disable the Quit HyperCard menu item and its command-key equivalent,
you need to trap the doMenu message (which is sent when the user selects
Quit or presses command-Q) as follows:

on doMenu theItem
  if theItem is "Quit HyperCard" then
    beep
    answer "Click one of the Quit buttons to quit."
  else
    pass doMenu -- DO NOT UNDER ANY CIRCUMSTANCES FORGET THIS LINE!
  end if
end doMenu

Note: If the quit buttons use the doMenu command to get out of the stack,
the above handler will trap the message and prevent it from being executed.
To prevent this, instead of
  doMenu "Quit HyperCard"
in the button script, use
  send "doMenu" && quote & "Quit HyperCard" & quote to HyperCard
This will bypass the doMenu handler.
-- 
====== jeanne a. e. devoto ========================================
 jdevoto@apple.com  |  You may not distribute this article under a
 jdevoto@well.UUCP  |  compilation copyright without my permission.
___________________________________________________________________
 Apple Computer and I are not authorized  |        CI$: 72411,165
 to speak for each other.                 |  AppleLink: SQA.TEST

tim@hoptoad.uucp (Tim Maroney) (12/09/89)

In article <EZTGqLG00WB5Q382YJ@andrew.cmu.edu> jk4i+@andrew.cmu.edu
(John McCall Kingsley, III) writes:
>I am trying to figure out a way that I can diable the user from using
>command-q and closing the stack, in my application the user must quit
>using one of my quit buttons, otherwise the databases get messed up, so
>is there anyway to trap the command-q and return to the card that you
>were on at the time of the command-q

on doMenu w
	if w is not "Quit Hypercard" then pass doMenu
end doMenu

This will also intercept "domenu 'Quit HyperCard'" from your buttons,
so bypass it on your own "quit" button:

	send "doMenu " & quote & "Quit HyperCard" & quote to HyperCard

Incidentally, rather than disabling Command-Q, why not make it equivalent
to your quit button?  That would make the script above be:

on doMenu w
        if w is not "Quit Hypercard" then pass doMenu
	send mouseUp to button "Quit"
end doMenu
-- 
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com

"The time is gone, the song is over.
 Thought I'd something more to say." - Roger Waters, Time