Xref: utzoo comp.windows.x:14501 comp.windows.news:1591 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!rutgers!bellcore!spectral!sjs From: sjs@spectral.ctt.bellcore.com (Stan Switzer) Newsgroups: comp.windows.x,comp.windows.news Subject: Re: Help with double-click recognition. Message-ID: <18012@bellcore.bellcore.com> Date: 23 Oct 89 13:20:23 GMT References: <603@granite.dec.com> <1922@bacchus.dec.com> <1490@esquire.UUCP> Sender: news@bellcore.bellcore.com Reply-To: sjs@bellcore.com (Stan Switzer) Organization: Bellcore Lines: 56 Well, frankly, it comes a quite a surprise to me that you can't do double click detection in X, but is quite easy in NeWS. Here's a routine to check if a click is, in fact, a double click. After you have detected a single click, invoke this routine to see if there is another click. Since it just checks to see if another click follows the current one, it can be cascaded to detect triple, quadruple, etc. clicks. /DoubleClickDelay .3 60 div def /DoubleClick? { % - -> another click(true) or not(false) null blockinputqueue { % fork ParentCanvas setcanvas currentcursorlocation createevent dup begin /Name /MouseDragged def end expressinterest createevent dup begin /Action /DownTransition def /Exclusivity true def end expressinterest createevent dup begin /Name /Timer def end dup expressinterest createevent copy dup begin /TimeStamp currenttime DoubleClickDelay add def end sendevent unblockinputqueue WaitButIgnoreJiggle /Action get /DownTransition eq % Have we a click? } fork waitprocess } def /JiggleFudge 4 def /WaitButIgnoreJiggle { { % get events until something more than a % mouse jiggle happens awaitevent true % exit flag 1 index /Name get /MouseDragged eq { 1 index begin XLocation YLocation end % stk: origX origY event exflag X Y 4 index sub abs JiggleFudge le exch 5 index sub abs JiggleFudge le and { pop false } if % continue (don't exit) } if { exit } if pop } loop } def If you wanted to be more clever, you could download a global click processor that converted all multiple clicks into distinct events for distribution. It would probably be a bad idea, though, since it would make all single clicks just a little bit sluggish. Stan Switzer sjs@bellcore.com