Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!pasteur!agate!web8f.berkeley.edu!laba-5as From: laba-5as@web8f.berkeley.edu (Bob Heiney) Newsgroups: comp.sys.mac.programmer Subject: Re: WaitNextEvent question Message-ID: <8335@agate.BERKELEY.EDU> Date: 4 Apr 88 20:47:16 GMT References: <1988Apr1.120105.112@mntgfx.mentor.com> <5587@well.UUCP> Sender: usenet@agate.BERKELEY.EDU Reply-To: laba-5as@widow.berkeley.edu.UUCP (Bob Heiney) Organization: University of California, Berkeley Lines: 50 Keywords: WainNextEvent Multifinder sleeping background In article <5587@well.UUCP> mz@well.UUCP (Michael Zentner) writes: > > >The mouse (RgnHandle) param is used to allow non-critical mouse movements. >It specifies a region within which you don't care if the mouse moves around, >like the cursor doesn't change, etc. If the mouse moves outside this region, >the application will get a "moused moved" event, which is a null event with >new mouse co-ordinates. > WaitNextEvent does not send a null event for mouse-moved. Instead, it sends the MultiFinder event (app4Evt) and the high byte of the message longint is $FA. The low 3 bytes are reserved by Apple. Upon receiving this event, an application should figure out what the proper cursor should be and then figure out a new mouse region. The point to this is that your application can give up lots of time to background tasks if it is in the foreground without worrying about the user moving the mouse somewhere where a cursor-change would have to occur. I've used WaitNextEvent in a text-editing application and it works great. If the mouse in in my current window, then the cursor is an I-beam, and the mouse region is just the viewRect of my TextEdit record. Note that this region is in GLOBAL coordinates (see the MultiFinder developer's package for the note on this). When the users moves out of the region, my application wakes up and calls a routine I have, FixCursor, that makes the cursor whatever it should be (usually an arrow), and sets the mouse region to be all of the screen EXCEPT for the viewRect. Those wishing to be Mac II compatible should use GetGrayRgn (or is it GetGreyRgn?) to get the region for the screen, since there can be more than one screen in the system. Here's a sample code fragment: tempRect:=myTextHandle^^.viewRect; LocalToGlobal(tempRect.topLeft); LocalToGlobal(tempRect.botRight); RectRgn(mouseRgn,tempRect); { I believe this is the call, but I'm typing from memory :-) } DiffRgn(GetGrayRgn,mouseRgn,mouseRgn); { now mouseRgn is the entire screen except for a hole where viewRect is } One more thing: Applications that use TextEdit have to wake up every now and then to call TEIdle. A sleep time of 20 ticks seems to be good. ---------------------------------------------------------------------- "... To boldly go where no one has gone before!" Bob Heiney laba-5as@widow.berkeley.edu