Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!pasteur!helios.ee.lbl.gov!ux1.lbl.gov!beard From: beard@ux1.lbl.gov (Patrick C Beard) Newsgroups: comp.sys.mac.programmer Subject: Re: Double Clicking Message-ID: <1967@helios.ee.lbl.gov> Date: 23 Feb 89 18:33:53 GMT References: <4452@hubcap.UUCP> Sender: usenet@helios.ee.lbl.gov Reply-To: beard@ux1.lbl.gov (Patrick C Beard) Organization: Lawrence Berkeley Laboratory, Berkeley Lines: 31 In article <4452@hubcap.UUCP> mikeoro@hubcap.UUCP (Michael K O'Rourke) writes: >A couple months ago, someone posted some example code to detect a double click. >I want to detect a double click in the title bar of a window. The easiest way to detect a double click is to save the time of each mouse down event in some variable, say lastClickTime. To detect if the next click should be interpreted as a double click, subtract this time from the time of the next click and compare it to the result of the GetDblTime() trap. i.e.: long lastClickTime=0; . . . /* assume we've been keeping track of lastClickTime... */ if(event.what==mouseDown) { if(event.when-lastClickTime<=GetDblTime()) { ProcessDoubleClicks(); lastClickTime=0; /* reset it */ } else lastClickTime=event.when; } Hope that helps. +----------------------------------------------------------------+ \ Patrick Beard "Badges? \ \ Berkeley Systems I ain't got to show you... \ \ PCBeard@lbl.gov ...NO STINKING BADGES!" \ + ---------------------------------------------------------------+