home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / next / programm / 8057 < prev    next >
Encoding:
Text File  |  1993-01-11  |  2.1 KB  |  64 lines

  1. Newsgroups: comp.sys.next.programmer
  2. Path: sparky!uunet!cs.utexas.edu!sun-barr!ames!agate!pasteur!cory.Berkeley.EDU!pkim
  3. From: pkim@cory.Berkeley.EDU (-)
  4. Subject: window dragging
  5. Message-ID: <1993Jan11.055510.28662@pasteur.Berkeley.EDU>
  6. Sender: nntp@pasteur.Berkeley.EDU (NNTP Poster)
  7. Nntp-Posting-Host: cory.berkeley.edu
  8. Organization: University of California, at Berkeley
  9. Date: Mon, 11 Jan 1993 05:55:10 GMT
  10. Lines: 52
  11.  
  12. i'm having a problem getting a window to drag properly when the user drags in
  13. a view within the window (the window is a NX_PLAINSTYLE window so it has no
  14. titlebar).  it seems to work fine except that every now and then, the window
  15. "vibrates" around the mouse point.  for example, if i start dragging the
  16. window to the left, the window, every now and then, will oscillate in a 
  17. circular  fashion for a  half a second.  the amplitude of the oscillations
  18. sometimes reaches a hundred pixels or so.
  19. here's the code (it should be pretty straightforward):
  20. - mouseDown:(NXEvent *)theEvent
  21. {
  22.     NXPoint    current;
  23.     NXCoord    dx, dy;
  24.     NXRect    wframe;
  25.     BOOL    tracking = YES;
  26.     int        mask;
  27.  
  28.     mask = [window addToEventMask:NX_MOUSEDRAGGEDMASK];
  29.  
  30.     current = theEvent->location;
  31.     [window getFrame:&wframe];
  32.     [window convertBaseToScreen:&last];
  33.     dx = NX_X(&wframe) - current.x;
  34.     dy = NX_Y(&wframe) - current.y;
  35.     theEvent = [NXApp getNextEvent:MOVE_MASK];
  36.     if (theEvent->type == NX_MOUSEUP) {
  37.     return self;
  38.     }
  39.  
  40.     while (tracking) {
  41.     current = theEvent->location;
  42.     [window convertBaseToScreen:¤t];
  43.     [window moveTo:(current.x + dx) :(current.y + dy)];
  44.     tracking = (theEvent->type != NX_MOUSEUP);
  45.     if (tracking) {
  46.         NXPing();
  47.         theEvent = [NXApp getNextEvent:MOVE_MASK];
  48.     }
  49.     }
  50.     [window setEventMask:mask];
  51.  
  52.     return self;
  53. }
  54.  
  55. i can't use dragFrom::theEvent: because i need to move other windows with this
  56. one (dragFrom::theEvent: doesn't send window update messages to the delegate).
  57. so, if anyone can either find the error in my code or tell me of another way
  58. to get several windows to move in tandem with the one the user is dragging,
  59. let me know.
  60.  
  61. thanks in advance,
  62. paul kim
  63. pkim@cory.berkeley.edu
  64.