home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!kithrup!stanford.edu!ames!haven.umd.edu!darwin.sura.net!dtix!mimsy!ra!peyton@itd.nrl.navy.mil
- From: peyton@itd.nrl.navy.mil (Rodney D. Peyton,B16/R132,X79091,)
- Newsgroups: comp.windows.x
- Subject: Young and Pew's Tracker2 Example
- Message-ID: <3410@ra.nrl.navy.mil>
- Date: 20 Aug 92 22:25:25 GMT
- Sender: usenet@ra.nrl.navy.mil
- Reply-To: peyton@itd.nrl.navy.mil
- Organization: Information Technology Division, Naval Research Laboratory
- Lines: 26
-
- I am in the process of teaching myself X window programming. I've
- started by working through Young and Pew's book titled "The X Window
- System Programming and Applications with Xt" the Open Look Edition. In
- chapter 5 there is an example program that tracks the mouse pointer.
- The example on page 200 suppose to track the mouse only while a mouse
- button is pressed. I compiled this example (I got the code from
- expo.lcs.mit.edu) and noticed that the pointer was continuously
- tracked. My solution to the problem was to check the XMotionEvent
- structure to see if the any keys (button1) were pressed before calling xs_wprintf,
- i.e,
-
- in track_mouse_position() I replaced
-
- xs_wprintf(tracker, "X: %4d, Y: %4d", event->xmotion.x, event->xmotion.y);
-
- with
-
- if (event->xmotion.state == Button1Mask)
- xs_wprintf(tracker, "X: %4d, Y: %4d", event->xmotion.x,
- event->xmotion.y);
-
- was this the correct thing to do ? I don't see why it was necessary since
- the event handler was created with
-
- XtAddEventHandler(target, Button1MotionMask | Button2MotionMask, FALSE,
- track_mouse_position, tracker);
-