Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!snorkelwacker!usc!cs.utexas.edu!mailrus!cornell!biar!trebor From: trebor@biar.UUCP (Robert J Woodhead) Newsgroups: comp.sys.mac.programmer Subject: Re: Line selection algorithims.. Message-ID: <981@biar.UUCP> Date: 16 Dec 89 19:15:02 GMT References: <8912160053.AA00720@cadman.nyu.edu> Organization: Biar Games, Inc. Lines: 31 deragon@CADMAN.NYU.EDU (John Deragon) writes: > I was wondering how the current applications like >MacDraw, MacDraft...etc etc do the line selection. For example in >MacDraw you click on the line and it becomes selected? How does it >do this? What is it testing on mouseDown? I don't know how THEY do it, but at first thought, the way I would do it is as follows: 1) Note that every object has an associated rectangle that contains it. 2) When a mouseDown occurs, we can check the position against the rectangles for the objects, in order of the object's frontness. 3) If this matches, we then go into a special checking routine, one for each object type, that does any special checks needed to determine if there is really a hit. The most obvious optimization is to note that objects not in display cannot be clicked on; thus anytime we scroll the window, generate a list of all the objects that intersect it (easy to do since we have to find them to display them) - then on clicks we only have to search this subset. -- Robert J Woodhead, Biar Games, Inc. !uunet!biar!trebor | trebor@biar.UUCP Announcing TEMPORAL EXPRESS. For only $999,999.95 (per page), your message will be carefully stored, then sent back in time as soon as technologically possible. TEMEX - when it absolutely, postively has to be there yesterday!