Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!pasteur!agate!wheatena!lippin
From: lippin@wheatena.berkeley.edu (The Apathist)
Newsgroups: comp.sys.mac.programmer
Subject: Re: Double Clicking
Message-ID: <13324@agate.BERKELEY.EDU>
Date: 16 Aug 88 01:40:06 GMT
References: <10014@reed.UUCP>
Sender: usenet@agate.BERKELEY.EDU
Reply-To: lippin@math.berkeley.edu
Organization: Authorized Service, Incorporated
Lines: 27

A double click occurs when a mouseDown event follows a mouseUp event
and they are sufficiently close in both space and time.  "Sufficiently
close" in space is application dependent; IM recommends five pixels
for graphics, and on the same character boundary for text.
"Sufficiently close" in time is returned by the call GetDblTime.

Thus, to handle double clicks, you should do something like this:

On mouseUp events, record the time and place that they occur.

On mouseDown events, compare the time and place to the last mouseUp.
If they are close enough, do your double click thing, otherwise, treat
it as a single click.  If your single click routine handles dragging,
it should use StillDown, not WaitMouseUp.

Note that with this algorithm, a double click is treated as an add-on
to a single click.  This is usually appropriate, as a double click
should be a semantic extension of a single click.  If you don't want
this, you'll have to either wait around after clicks to make sure they
aren't double (which can be sluggish), or undo the single click when
the second click comes in (which may be more difficult to program).

					--Tom Lippincott
					..ucbvax!math!lippin

	"Thank you for observing all saftey precautions."
					--Dark Star