Path: utzoo!attcan!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: <23260@santra.UUCP> Date: 27 Jun 89 23:16:21 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: 50 In article <2509@internal.Apple.COM> lsr@Apple.COM (Larry Rosenstein) writes: >Perhaps you can elaborate on why this does not work with QuicKeys; the >code does take into account mouseUp events. It took some writing to find this out and even then I can only guess at what happens. The assumptions I make here are based on the following code fragment and quickeys behavior with it: int ClickRect(box) Rect *box; { EventRecord myEvent; register int hilited=0,where; do { GetNextEvent(mUpMask,&myEvent); GlobalToLocal(&myEvent.where); where=PtInRect(myEvent.where,box); if(where!=hilited) { hilited=where; InvertRect(box); } } while(myEvent.what!=mouseUp); if(hilited) InvertRect(box); return hilited; } What happens is that the mouseup is never detected. You have to click somewhere outside the "button" to release the control. If you define the click so that the mouse moves even a single pixel, both versions will work. Neither works if the mouse doesn't move. I assume that quickeys doesn't bother to post a mouseup if the mouse position doesn't change. (I'd call that a bug.) The above code is still preferable because it handles event buffering correctly. You can click on buttons while a program is calculating and the program will behave correctly. IM-I-36: >The system provides a "mouse-ahead"; that is, any mouse actions the user >performs when the application isn't ready to process them are saved in a >buffer and can be processed at the apllication's convenience. Alternatively, >the application can choose to ignore saved-up mouse actions, but should do >so only to protect the user from possibly damaging consequences. _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ | Juri Munkki jmunkki@hut.fi jmunkki@fingate.bitnet I Want Ne | | Helsinki University of Technology Computing Centre My Own XT | ^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^