home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / mac / programm / 21332 < prev    next >
Encoding:
Text File  |  1993-01-12  |  1.7 KB  |  42 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!munnari.oz.au!uniwa!cujo!ncrpda.curtin.edu.au!rocky.curtin.edu.au!user
  3. From: peter@cujo.curtin.edu.au (Peter N Lewis)
  4. Subject: Re: Detecting mouse position in a window ?
  5. Message-ID: <peter-130193090353@rocky.curtin.edu.au>
  6. Followup-To: comp.sys.mac.programmer
  7. Lines: 28
  8. Sender: news@ncrpda.curtin.edu.au
  9. Nntp-Posting-Host: ncrpda.curtin.edu.au
  10. Organization: NCRPDA, Curtin University
  11. References: <rudolph.726810080@unixg.ubc.ca> <1993Jan12.050224.14617@magnus.acs.ohio-state.edu>
  12. Date: Wed, 13 Jan 1993 01:05:03 GMT
  13.  
  14. In article <1993Jan12.050224.14617@magnus.acs.ohio-state.edu>,
  15. jbush@magnus.acs.ohio-state.edu (J Eric Bush) wrote:
  16. > In article <rudolph.726810080@unixg.ubc.ca> rudolph@unixg.ubc.ca 
  17. > (Christopher E Rudolph) writes:
  18. > >I obviously need to be checking where the mouse is at any one time and act
  19. > >appropriately.  Does anyone have an example of how to do this gracefully.
  20. > >thanks, and sorry about it begin an FAQ
  21. > Just use the GetMouse(p:point) procedure.  If at first it gives you a global 
  22. > point, then all you have to do it say point:=GlobalToLocal(p).
  23.  
  24. Don't forget to SetPort to the window before using GlobalToLocal.
  25.  
  26. Also, if you want to find out the mouse position in a background only app,
  27. you can use the event.where field from OSEventAvail (the most common reason
  28. for that is to detect when the mac is idle) (because GetMouse will crash if
  29. you haven't inited all the relevent managers).
  30.  
  31. GetMouse(VAR_mouseLoc_Point);
  32. BOOLEAN:=OSEventAvail(mask_INTEGER,VAR_theEvent_EventRecord);
  33.  
  34. Have fun,
  35.    Peter.
  36.  
  37. _______________________________________________________________________
  38. Peter N Lewis <peter@cujo.curtin.edu.au>             Ph: +61 9 368 2055
  39.