[comp.sys.mac.hypercard] Preventing Mouse-Click Actions

peggyl@ashtate.UUCP (Peggy Lerch) (06/01/89)

Is there any way to prevent a button script from executing if
the mouse button is clicked while the script is already executing?
I'm trying to write educational stacks for my three-year old who
goes click-crazy and then has to wait for a long time for the
script to stop repeating itself.

Thanks in advance.

Peggy Lerch
Ashton-Tate

mesard@bbn.com (Wayne Mesard) (06/01/89)

In article <619@ashtate.UUCP> peggyl@ashtate.UUCP (Peggy Lerch) writes:
>Is there any way to prevent a button script from executing if
>the mouse button is clicked while the script is already executing?

Well, the process isn't interrupt driven.  That is, it doesn't run the
second time until the first invocation is finished.  In other words,
Hypercard records the second mouse click, but doesn't do anyting with it
until the script is done running and Hypercard is looking for something
to do.

So your question is really: "Is there any way to prevent a script from
running if it was run recently?"

Here are two approaches:

 o  You could have the script record the time at which it ran in a
    global variable.  Then, at the top of the script, compare this value
    to the current time, and if the difference is less than N ticks
    don't run the script again (or beep, or tell the user to take a
    tranquilizer or something).

 o  At the end of the script(s) set a global variable (e.g. canRun) to
    true.  At the beginning add a conditional like "if canRun = true
    then exit MouseUp" (or beep and exit or whatever).  Then, have an
    idle handler that sets the variable to false.  Thus, the script(s)
    will only run if there was an idle event between invocations.

Notes:

 o These are untested and off the top of my head.
 o I like the second approach better.

>I'm trying to write educational stacks for my three-year old who
>goes click-crazy and then has to wait for a long time for the
>script to stop repeating itself.

Oh.  Forget what I said about the tranquilizers then :-)  This could
also be useful for Hypercard neophytes who are forever double-clicking,
since that's what they're used to from using the Finder.

-- 
unsigned *Wayne_Mesard();     POKE 59468,16
MESARD@BBN.COM                
BBN, Cambridge, MA           

jlc@atux01.UUCP (J. Collymore) (06/02/89)

In article <40759@bbn.COM>, mesard@bbn.com (Wayne Mesard) writes:
> In article <619@ashtate.UUCP> peggyl@ashtate.UUCP (Peggy Lerch) writes:
> >Is there any way to prevent a button script from executing if
> >the mouse button is clicked while the script is already executing?
> 
> Here are two approaches:
> 
>  o  You could have the script record the time at which it ran in a
>     global variable.  Then, at the top of the script, compare this value
>     to the current time, and if the difference is less than N ticks
>     don't run the script again (or beep, or tell the user to take a
>     tranquilizer or something).
> 
> >I'm trying to write educational stacks for my three-year old who
> >goes click-crazy and then has to wait for a long time for the
> >script to stop repeating itself.
> 
> This could also be useful for Hypercard neophytes who are forever
> double-clicking, since that's what they're used to from using the Finder.

I just thought that if this was implemented using a verbal response from
either MacinTalk, or A digitized voice (as in using "MacRecorder" by Farallon
Computing), this might be especially effective for young children.

For example, after creating such a script you could have a message kick in
that said:  "Please don't click the mouse so much or so fast!"  To a young
child I would expect that this would have one of three effects:

1)  Either it startled the child enough to obey the recorded command,

2)  THe child would double-click MORE OFTEN for the "fun" of hearing the
    computer speak,

3)  THe child would ignore the computerized command altogether.

Anyway, it might be worth trying.


						Jim Collymore

al@mtcs.UUCP (Al Fontes) (06/03/89)

From article <619@ashtate.UUCP>, by peggyl@ashtate.UUCP (Peggy Lerch):
> Is there any way to prevent a button script from executing if
> the mouse button is clicked while the script is already executing?

Try:
set lockMessages to true

taylorj@yvax.byu.edu (06/03/89)

I've been meaning to try this, so I don't know for sure if it will work, but I
think if you put a "wait until the mouse is up" message at the end of your
script, it will flush any mouseclicks that occured while the script was
running.  If it works, let me know...

Jim Taylor
Microcomputer Support for Curriculum
Brigham Young University
taylorj@byuvax.bitnet

peggyl@ashtate.UUCP (Peggy Lerch) (06/06/89)

In article <622taylorj@yvax.byu.edu>, taylorj@yvax.byu.edu writes:
> I've been meaning to try this, so I don't know for sure if it will work, but I
> think if you put a "wait until the mouse is up" message at the end of your
> script, it will flush any mouseclicks that occured while the script was
> running.  If it works, let me know...
> 
> Jim Taylor
> Microcomputer Support for Curriculum
> Brigham Young University
> taylorj@byuvax.bitnet

Jim,

This easy solution worked great!  Thanks.

Peggy Lerch
Ashton-Tate