ack@eleazar.Dartmouth.EDU (Andy J. Williams) (04/27/88)
[] I am writing a screen saver (isn't everyone these days) which will terminate with a KeyDownMask, MouseDownMask and many of the other standard things which make screen savers go bye bye. The only one I cannot get is MouseMoved. There is no provision for this in the toolbox that I have seen, so how do I trap this event? Is it as simple as GetMouse each time through the loop with a comparison to where the Mouse was last, or is there another way? Also: This is being set up as an INIT/CDEV. Exactly how do I structure the loop which counts idle time/waits for the mouse to go into the magic corner, so that all other system events run around me. I saw the LSC Init code here but am writing this in LSPascal so it was not much help (my knowledge of C is rather small at this time). Thanks for any help! -Andy Wafna! -- Andy J. Williams '90 |Ack Systems: ack@eleazar.dartmouth.edu| _ /| Software Development +--------------------------------------+ \`o_O' ACK! Kiewit Computation Center|Hello. My $NAME is ~inigo_montoya. | ( ) / Dartmouth College |You killed my process. Prepare to vi.| U
alibaba@ucscb.UCSC.EDU (Alexander M. Rosenberg) (04/29/88)
I wish I knew more about this offhand, but other than doing it the way you described, using GetMouse, you might take a look at the low-memory globals. I think that there is a global there that might do some of the work for you. Check in Scott Knaster's "How to Program Macintosh Software" or in the appropriate "Macintosh Revealed" volume. ------------------------------------------------------------------------------- - Alexander M. Rosenberg - INTERNET: alibaba@ucscb.ucsc.edu - Yoyodyne - - Crown College, UCSC - UUCP:...!ucbvax!ucscc!ucscb!alibaba- Propulsion - - Santa Cruz, CA 95064 - BITNET:alibaba%ucscb@ucscc.BITNET - Systems - - (408) 426-8869 - Disclaimer: Nobody is my employer - :-) - - - so nobody cares what I say. - -
oster@dewey.soe.berkeley.edu (David Phillip Oster) (05/01/88)
In article <3068@saturn.ucsc.edu> alibaba@ucscb.UCSC.EDU (Alexander M. Rosenberg) writes: >described, using GetMouse, you might take a look at the low-memory globals. >I think that there is a global there that might do some of the work for you. Of course, if you do this you will instantly be incompatible with many keyboard macro packages, third party tablet drivers, journaling packages, and possibly Apple's future operating systems. In general, unless there is a really good reason, and you plan to support the program forever or the program is only for private use, if a tooltrap exists that returns the value of a global, use the trap and not the global. It will save you a lot of grief when the system changes. If you care, profile your code, and see how it runs with direct access to the global versus via the trap. You'll often find that doing ti the right way doesn't actually cost you any speed. If you are running under multifinder, WaitNextEvent returns mouseMoved as a nullEvent with a bit set (in the message field?, in the modifers field?) if the mouse moved outside the region you hand WaitNextEvent. If you are not running under multifinder, it does no harm to just call GetMouse(). --- David Phillip Oster --When you asked me to live in sin with you Arpa: oster@dewey.soe.berkeley.edu --I didn't know you meant sloth. Uucp: {uwvax,decvax,ihnp4}!ucbvax!oster%dewey.soe.berkeley.edu
thomas@uvabick.UUCP (Thomas Fruin) (05/02/88)
David Phillip Oster writes: > If you are running under multifinder, WaitNextEvent returns mouseMoved as > a nullEvent with a bit set (in the message field?, in the modifers > field?) if the mouse moved outside the region you hand WaitNextEvent. If you aren't running under MultiFinder, you can examine the EventRecord for null events. Even though no event is being reported, the where field will still hold the current mouse position. Compare it to an initial position you saved previously, and you've got your mouseMoved event. -- Thomas Fruin fruin@hlerul5.BITNET University of Leiden thomas@uvabick.UUCP University of Amsterdam hol0066.AppleLink 2:512/114.FidoNet The Netherlands
lsr@Apple.COM (Larry Rosenstein) (05/03/88)
In article <23826@ucbvax.BERKELEY.EDU> oster@dewey.soe.berkeley.edu.UUCP (David Phillip Oster) writes: >In article <3068@saturn.ucsc.edu> alibaba@ucscb.UCSC.EDU (Alexander M. Rosenberg) writes: >>described, using GetMouse, you might take a look at the low-memory globals. >>I think that there is a global there that might do some of the work for you. > >Of course, if you do this you will instantly be incompatible with The low memory mouse variables are not documented very well (if at all), which means that they can be changed in the future. You should definitely call a trap to get the mouse position. GetMouse will return the mouse in local coordinates, which is probably not what you want. Instead, all OSEventAvail with a mask of 0. OSEventAvail returns the mouse in global (screen) coordinates. If you are really concerned about performance, then use GetTrapAddress to find out the address of the OSEventAvail trap and call it directly. The only risk in doing this is that some other code might patch OSEventAvail and you wouldn't be using the patched code. (This won't cause system problems, because any system patches are installed before INITs are run. The problem might show up as an incompatibility with some other INIT.) >If you are running under multifinder, WaitNextEvent returns mouseMoved as >a nullEvent with a bit set (in the message field?, in the modifers It returns an app4Evt, not a null event. The high byte of the message field distinguishes a mouse moved event from a suspend/resume event. -- Larry Rosenstein, Object Specialist Apple Computer, Inc. 20525 Mariani Ave, MS 27-AJ Cupertino, CA 95014 AppleLink:Rosenstein1 domain:lsr@Apple.COM UUCP:{sun,voder,nsc,decwrl}!apple!lsr