Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!cs.utexas.edu!uunet!mcvax!kth!draken!tut!santra!kampi.hut.fi!jmunkki From: jmunkki@kampi.hut.fi (Juri Munkki) Newsgroups: comp.sys.mac.programmer Subject: Re: TrackButton() Message-ID: <23257@santra.UUCP> Date: 27 Jun 89 22:19:47 GMT References: <128@dbase.UUCP> <23239@santra.UUCP> <2509@internal.Apple.COM> Sender: news@santra.UUCP Reply-To: jmunkki@kampi.hut.fi (Juri Munkki) Organization: Helsinki University of Technology, Finland Lines: 54 In article <2509@internal.Apple.COM> lsr@Apple.COM (Larry Rosenstein) writes: >In article <23239@santra.UUCP> jmunkki@kampi.hut.fi (Juri Munkki) writes: >> What if the user quickly presses and releases the mouse button on the >> control and then moves the mouse away from the button area. Your routine >> does not detect this. You should use GetNextEvent to find when the button > >The example code called StillDown which seems to be the right thing to do. > StillDown returns FALSE if the event queue contains a mouseUp event, >which would handle the case you describe. (You can also call WaitMouseUp, >which does the same thing and removes the mouseUp from the event queue.) You still get the wrong mouse coordinates if you use stilldown/getmouse. With GetNextEvent you get the coordinate where the mouseup happened. GetMouse just tells you the current mouse locations. These are not the same thing. >Perhaps you can elaborate on why this does not work with QuicKeys; the >code does take into account mouseUp events. Ok. Here's the code I used in my Mandelbrot DA. /* A general purpose pseudo-button ** handler. Give it a rect and it ** handles the rectangle as a button ** and returns true if the button was ** hit. */ int ClickRect(box) Rect *box; { register int hilited=0,where; Point spot; while(StillDown()) { GetMouse(&spot); where=PtInRect(spot,box); if(where!=hilited) { hilited=where; InvertRect(box); } } if(hilited) InvertRect(box); return hilited; } Now take a look at the code that was posted. There are some very minor differences, but basically it's the same program. I don't know how QuicKeys is supposed to work, but defining a click in the box does not produce the expected results. _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ | Juri Munkki jmunkki@hut.fi jmunkki@fingate.bitnet I Want Ne | | Helsinki University of Technology Computing Centre My Own XT | ^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^