Path: utzoo!attcan!uunet!iconsys!tom From: tom@iconsys.UUCP (Tom Kimpton) Newsgroups: comp.sys.mac.programmer Subject: Re: Double Clicking Message-ID: <341@iconsys.UUCP> Date: 24 Feb 89 23:45:27 GMT References: <4452@hubcap.UUCP> <1967@helios.ee.lbl.gov> Reply-To: tom@iconsys.UUCP (Tom Kimpton) Organization: ICON International, Inc., Orem, UT Lines: 62 In article <1967@helios.ee.lbl.gov> beard@ux1.lbl.gov (Patrick C Beard) writes: >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. > As well you would want to keep the location of the last click and check to see if both it and the current location are in an appropriate selection rectangle. F o d d e r F o d d e r F o d d e r -- Tom Kimpton UUCP: {uunet,caeco,nrc-ut}!iconsys!tom Software Development Engineer ARPANET: icon%byuadam.bitnet@cunyvm.cuny.edu Icon International, Inc. BITNET: icon%byuadam.bitnet (multi-user acct) Orem, Utah 84058 PHONE: (801) 225-6888