Path: utzoo!attcan!uunet!bu.edu!snorkelwacker!apple!apple.com!rmh From: rmh@apple.com (Rick Holzgrafe) Newsgroups: comp.sys.mac.hypercard Subject: Re: Misc Easy HC Questions Message-ID: <10179@goofy.Apple.COM> Date: 12 Sep 90 19:37:19 GMT Sender: usenet@Apple.COM Organization: Apple Computer, Inc. Lines: 68 References:<11792@crdgw1.crd.ge.com> <10164@goofy.Apple.COM> In article <10164@goofy.Apple.COM> Griffiths.R@AppleLink.Apple.com (Rob Griffiths) writes: > on mouseup > put the ticks into TM > repeat until the mouseclick > if (the ticks - TM) > 20 then > -- too much time has transpired, cancel the handler. > -- or, alternatively, perform a single-click action. > -- (vary the double-click response speed by changing the "20" > -- to another number, either higher or lower.) > exit mouseup > end if > end repeat > -- if we get here, user has double clicked > -- so, put double-click action here! > end mouseup > > Just attach this to the object you wish to check, and add the code to > perform whatever actions you desire. One nice side benefit is that you > can make a single click perform one action (for instance, display a menu), > and a double click another (go directly to some card). Just a friendly warning... the Apple Thought Police will getcha if you break a basic rule about clicking: NEVER WAIT FOR THE SECOND CLICK. You should do something immediately when you receive the first click, then something in addition when you receive the second. That way response to every click can be as fast as possible. The handler above, on the other hand, twiddles its thumbs while waiting for further orders from the user. (I know that HyperCard is slow enough that the difference may not be so noticable. But Macs are getting faster, and HC 2.0 is supposed to really zip along. And nobody likes to wait!) Instead, I'd suggest something like the following, placed in the script of your stack. (Forgive any syntax errors, this is typed on the fly.) function isDoubleClick global lastClickTime, lastClickItem put the ticks into TM if TM - lastClickTime < 20 and the id of the target is lastClickItem then return true else put TM into lastClickTime put the id of the target into lastClickItem return false end if end isDoubleClick Then do something like this in the script of each double-clickable item: on mouseup if isDoubleClick then -- do double-click stuff else -- do single-click stuff end if end mouseUp Now, don't flame me about any of this - I don't work for the ATP. I just don't like seeing people dragged screaming from their beds in the middle of the night. :-) :-) :-) ========================================================================== Rick Holzgrafe | {sun,voder,nsc,mtxinu,dual}!apple!rmh Software Engineer | AppleLink HOLZGRAFE1 rmh@apple.com Apple Computer, Inc. | "All opinions expressed are mine, and do 20525 Mariani Ave. MS: 3-PK | not necessarily represent those of my Cupertino, CA 95014 | employer, Apple Computer Inc."