[comp.sys.mac.hypercard] Double Clicking on Buttons

alan@aic.hrl.hac.com (Alan Nakamura (213)317-5684) (09/12/90)

Is there an easy way to allow for double clicking on buttons?  Many
Macintosh users who are unfamiliar with HyperCard have the habit of
double clicking icons and become annoyed when they double click of a
navigation button only to go forward/backward two steps instead of one. 
This is probably a trivial task, but one that should be employed in more
stacks!  Thanks!!!

(I take it from the lack of response to a previous question on fields
that scroll horizontally that this is either not trivial, or not
something others think is useful)


Alan Nakamura
Hughes Research Labs
Artificial Intelligence Center
alan@aic.hrl.hac.com 

taylorj@yvax.byu.edu (09/12/90)

In <10503@hacgate.UUCP>, alan@aic.hrl.hac.com (Alan Nakamura) writes:

>Is there an easy way to allow for double clicking on buttons? Many
>Macintosh users who are unfamiliar with HyperCard have the habit of
>double clicking icons and become annoyed when they double click of a
>navigation button only to go forward/backward two steps instead of one.

The lazy solution here is to trap double clicks of the mouse.  In the stack
script, put a handler something like

  on ignoreClicks
    wait while the mouseClick
  end ignoreClicks

the add an "ignoreClicks" line at the end of each script where the user may
have double clicked, or before each script where the user may have double
clicked.  (Of course you can just use the "wait..." line itself if you prefer.)

There are a couple of ways to recognize double clicks.  If the script is long
enough that it takes a while to execute, you can just check "if the
mouseClick" near the end of the script.  (Don't use "if the mouse is down", it
won't always catch the click.)  This may not be a good idea because scripts
will run much faster in HC 2.0.  If you want to get fancy and do a good job,
try something like this

  on mouseUp
    put the ticks into start
    repeat until the ticks-start >= 50  -- or whatever time you want to allow
      if the mouseClick then
        -- do doubleclick stuff here or set a flag
        exit repeat
      end if
    end repeat
  end mouseUp

Even then, you'll still probably want to trap any stray clicks made by people
who don't double click fast enough.

>(I take it from the lack of response to a previous question on fields
>that scroll horizontally that this is either not trivial, or not
>something others think is useful)

It's not trivial.  You'll have to store the text in a separate field (because
you don't want it to wrap in the field you're displaying), and you'll have to
make a fake scrollbar with graphics and buttons.  Then, depending on the
position of the scrollbar, you'll have to determine the length in pixels of the
text not visible on the left (you can do this with an XFCN like my TextLength
function) until you get the right amount, then determine how many characters
fit in the visible part of the field (using the XFCN again), take that many
characters from the separate field ("get char x to y of line z of ...") and
put them in the display field.  You'll have to do that for every visible line
of text.  This will probably be so excrutiatingly slow that it won't be worth
it.

You could write an XFCN to do this all for you.  You just need to be familiar
with the Quickdraw text handling routines.  This would easily be fast enough,
but writing it would not be trivial.


Jim Taylor
Microcomputer Support for Curriculum   |
Brigham Young University               |   Bitnet: taylorj@byuvax.bitnet
101 HRCB, Provo, UT  84602             |   Internet: taylorj@yvax.byu.edu