Article View: comp.sys.next.programmer
Article #2281window dragging
From: -
Date: Mon, 11 Jan 1993 05:55
Date: Mon, 11 Jan 1993 05:55
52 lines
2213 bytes
2213 bytes
i'm having a problem getting a window to drag properly when the user drags in
a view within the window (the window is a NX_PLAINSTYLE window so it has no
titlebar). it seems to work fine except that every now and then, the window
"vibrates" around the mouse point. for example, if i start dragging the
window to the left, the window, every now and then, will oscillate in a
circular fashion for a half a second. the amplitude of the oscillations
sometimes reaches a hundred pixels or so.
here's the code (it should be pretty straightforward):
- mouseDown:(NXEvent *)theEvent
{
NXPoint current;
NXCoord dx, dy;
NXRect wframe;
BOOL tracking = YES;
int mask;
mask = [window addToEventMask:NX_MOUSEDRAGGEDMASK];
current = theEvent->location;
[window getFrame:&wframe];
[window convertBaseToScreen:&last];
dx = NX_X(&wframe) - current.x;
dy = NX_Y(&wframe) - current.y;
theEvent = [NXApp getNextEvent:MOVE_MASK];
if (theEvent->type == NX_MOUSEUP) {
return self;
}
while (tracking) {
current = theEvent->location;
[window convertBaseToScreen:¤t];
[window moveTo:(current.x + dx) :(current.y + dy)];
tracking = (theEvent->type != NX_MOUSEUP);
if (tracking) {
NXPing();
theEvent = [NXApp getNextEvent:MOVE_MASK];
}
}
[window setEventMask:mask];
return self;
}
i can't use dragFrom::theEvent: because i need to move other windows with this
one (dragFrom::theEvent: doesn't send window update messages to the delegate).
so, if anyone can either find the error in my code or tell me of another way
to get several windows to move in tandem with the one the user is dragging,
let me know.
thanks in advance,
paul kim
pkim@cory.berkeley.edu
Technical Details
Message-ID:
<1993Jan11.055510.28662@pasteur.Berkeley.EDU>Path:
arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!sun-barr!ames!agate!pasteur!cory.Berkeley.EDU!pkimShow Full Headers
Complete Article Headers
Newsgroups: comp.sys.next.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!sun-barr!ames!agate!pasteur!cory.Berkeley.EDU!pkim From: pkim@cory.Berkeley.EDU (-) Subject: window dragging Message-ID: <1993Jan11.055510.28662@pasteur.Berkeley.EDU> Sender: nntp@pasteur.Berkeley.EDU (NNTP Poster) Nntp-Posting-Host: cory.berkeley.edu Organization: University of California, at Berkeley Date: Mon, 11 Jan 1993 05:55:10 GMT Lines: 52