home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / mac / programm / 20737 < prev    next >
Encoding:
Internet Message Format  |  1993-01-06  |  1.6 KB

  1. Path: sparky!uunet!dtix!mimsy!mojo.eng.umd.edu!russotto
  2. From: russotto@eng.umd.edu (Matthew T. Russotto)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: Detecting mouseDown in a region?
  5. Message-ID: <1993Jan05.232933.21283@eng.umd.edu>
  6. Date: 5 Jan 93 23:29:33 GMT
  7. References: <1993Jan5.171920.29754@fsl.noaa.gov>
  8. Organization: Project GLUE, University of Maryland, College Park
  9. Lines: 27
  10.  
  11. In article <1993Jan5.171920.29754@fsl.noaa.gov> urban@yoda.fsl.noaa.gov (Art Urban) writes:
  12. >
  13. >Okay, here's the situation:
  14. >
  15. >I have many (let's say 1000) predefined regions in a window (CPane). When
  16. >the user clicks in the window, one of the regions will have neccessarilly
  17. >been hit, since they are all adjacent to one another. I need to determine
  18. >which region was the recipient of the mouseDown.
  19. >
  20. >Am I supposed to loop through all my regions, checking PtInRegion() for
  21. >each one until I get a hit? This seems very brute force, and could possibly
  22. >become slow if the user clicks in the 1000th region. Is there any way I can
  23. >reduce the possibilities?
  24.  
  25. You've mentioned the traditional way, and I believe one of the few ways
  26. will work for arbitrary regions.  The opposite extreme is to make a
  27. table mapping points to regions-- takes some setup and is memory
  28. intensive, but will work.  
  29.  
  30. If you know a little more about where the regions are, you could
  31. eliminate some of the regions based on, say, which quadrant the mouse
  32. was clicked on.
  33. -- 
  34. Matthew T. Russotto    russotto@eng.umd.edu    russotto@wam.umd.edu
  35. Some news readers expect "Disclaimer:" here.
  36. Just say NO to police searches and seizures.  Make them use force.
  37. (not responsible for bodily harm resulting from following above advice)
  38.