Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!nrl-cmf!ames!amdcad!sun!pitstop!sundc!seismo!uunet!mcvax!enea!kth!draken!tut!santra!kampi!jmunkki From: jmunkki@kampi.hut.fi (Juri Munkki) Newsgroups: comp.sys.mac.programmer Subject: Re: CDEF's Message-ID: <19204@santra.UUCP> Date: 1 Feb 89 08:41:52 GMT References: <5631@paris.ics.uci.edu> <19324@dhw68k.cts.com> Sender: news@santra.UUCP Reply-To: jmunkki@kampi.UUCP (Juri Munkki) Organization: Helsinki University of Technology, Finland Lines: 28 In article <19324@dhw68k.cts.com> thecloud@dhw68k.cts.com (Ken McLeod) writes: > It sounds like a CDEF may be overkill for what you want to do. Here's >a simple function I use for tracking rectangular buttons (replace the >calls to InvertRect() with InvertOval() if you want a circular button, >and so on). > while (Button()) { I used to track buttons this way myself (try my Mandelbrot DA), but discovered that QuicKeys does not work correctly with buttons that use "Button()" to determine when the mouse came up. I think the correct way to do this tracking is to use GetNextEvent to get a mouseUp event. { GetNextEvent(mUpMask+mDownMask,&Event); ... do your highlighting etc. here. } while(Event.what!=mouseUp); Now unhilite the button if it was hilited. Use Event.where to find if mouse was within button on mouseup... I don't know why I have the mDownMask there, but it doesn't seem to hurt and I remember putting it there for some reason... Your PtInRect/inverting routine can easily be optimized to about 1/2 size. _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ | Juri Munkki jmunkki@hut.fi jmunkki@fingate.bitnet I Want Ne | | Helsinki University of Technology Computing Centre My Own XT | ~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~