[comp.sys.mac.programmer] A BUG

rcook@eagle.wesleyan.edu (09/25/89)

Bug in the Finder!!

Some time ago I had written a program which ran perfectly, only when it
finished and returned to the Finder I discovered that I couldn't double- click
on anything anymore; pressing the mouse button twice merely selected the file,
but did not open it.  This only occurred in the Finder.  I could double click
to my hearts content in ResEdit or Word or LSP.  I suspected that I had
clobbered the global variable doubleTime, but I actually hadn't. 

After some investigation, I discovered that my program sets the system event
mask to disable the posting of MouseUp events, and the Finder needs MouseUps to
process a double click.  I tested this further with this 3 line wonder:

program test;
begin
  SetEventMask(EveryEvent - MUpMask);
end.

And sure enough, no double clicks.  All Finders up to the version that goes
with System 6.0.3 (and perhaps newer ones) can be brought to their knees by a
bad event mask, so watch out.  I'm surprised Larry, Steve, John, and Bruce (or
whoever they are) didn't set the mask just the way they want it when the Finder
starts up.  I suppose the rule shoule be that if you mess with the event mask,
set it to EveryEvent-KeyUpMask when the program finishes to avoid future
problems.

Tell me if you know anything more about this stuff.

                       --- Randall Cook
                           rcook%eagle@wesleyan.bitnet
                           rcook@eagle.wesleyan.bitnet

rang@cs.wisc.edu (Anton Rang) (09/25/89)

In article <1567@eagle.wesleyan.edu> rcook@eagle.wesleyan.edu writes:
>After some investigation, I discovered that my program sets the system event
>mask to disable the posting of MouseUp events, and the Finder needs MouseUps to
>process a double click.

  This is actually documented somewhere--if you change the event mask,
you must restore it after you exit.  (This changed sometime after
system 3.2, I believe.)  Also, setting the event mask is discouraged.
  I think this is related to changes in the way PostEvent and friends
work under MultiFinder.
   
+----------------------------------+------------------+
| Anton Rang (grad student)        | rang@cs.wisc.edu |
| University of Wisconsin--Madison |                  |
+----------------------------------+------------------+

"You are in a twisty little maze of Unix versions, all different."

mystone@caen.engin.umich.edu (Dean Yu) (09/25/89)

In article <1567@eagle.wesleyan.edu> rcook@eagle.wesleyan.edu writes:
>Bug in the Finder!!
>
>Some time ago I had written a program which ran perfectly, only when it
>finished and returned to the Finder I discovered that I couldn't double- click
>on anything anymore; pressing the mouse button twice merely selected the file,
>but did not open it.  This only occurred in the Finder.  I could double click
>to my hearts content in ResEdit or Word or LSP.  I suspected that I had
>clobbered the global variable doubleTime, but I actually hadn't. 
>
>After some investigation, I discovered that my program sets the system event
>mask to disable the posting of MouseUp events, and the Finder needs MouseUps to
>process a double click.  I tested this further with this 3 line wonder:
>
[stub deleted]
>
>And sure enough, no double clicks.  All Finders up to the version that goes
>with System 6.0.3 (and perhaps newer ones) can be brought to their knees by a
>bad event mask, so watch out.  I'm surprised Larry, Steve, John, and Bruce (or
>whoever they are) didn't set the mask just the way they want it when the Finder
>starts up.  I suppose the rule shoule be that if you mess with the event mask,
>set it to EveryEvent-KeyUpMask when the program finishes to avoid future
>problems.
>

  Nope, sorry, it's not a bug.  The definition of a double-click is if the time
between a mouse down and a mouse up is less than doubleTime, and the time
between that mouse up and the preceding mouse down is relatively short, then
you have a double click.  Most programs (including mine :) just check to make
sure that the time between mouse downs is less than doubleTime, and don't
worry about the intervening mouse up.  However, the Finder's method is correct.
(Hold down the mouse button for a second, let up, and click again real
quick.  Semantically, this is a double click, but most applications won't detect
it as one, but the Finder will.)
  Also, you shouldn't really be playing with the event mask.  And if you do,
you WERE supposed to reset it when you're application quits.  You should also
reset it in MultiFinder when you get a suspend event, since all applications
share the same event mask.

_______________________________________________________________________________
Dean Yu                            | E-mail: mystone@caen.engin.umich.edu
Self-declared License Czar         | Real-mail: Dean Yu
University of Michigan             |            909 Church St
Computer Aided Engineering Network |            Apt C
     INCLUDE 'Disclaimers.a'       |            Ann Arbor, MI 48104
-------------------------------------------------------------------------------

ech@cbnewsk.ATT.COM (ned.horvath) (09/26/89)

In article <1567@eagle.wesleyan.edu> rcook@eagle.wesleyan.edu writes:
>After some investigation, I discovered that my program sets the system event
>mask to disable the posting of MouseUp events, and the Finder needs MouseUps to
>process a double click.

If you look at the definition (IM I-37, "Multiple clicking"), you'll see
that the Finder is doing the right thing: double-click-time should be
compared to the time between mouse-up and the following mouse-down.

=Ned Horvath=

d88-jwa@nada.kth.se (Jon W{tte) (09/26/89)

In article <RANG.89Sep25091009@derby.cs.wisc.edu> rang@cs.wisc.edu (Anton Rang) writes:
>  This is actually documented somewhere--if you change the event mask,
>you must restore it after you exit.  (This changed sometime after
                     ^^^^^

Shouldn't that be BEFORE you exit ?! :')

h+@nada.kth.se
-- 
If God had intended Man to Drink, He would have given him a Funnel.