Re: Question concerning mouseDragged events.
Re: Question concerning mouseDragged events.
- Subject: Re: Question concerning mouseDragged events.
- From: Graham Reitz <email@hidden>
- Date: Tue, 27 May 2008 22:55:35 -0500
Thanks. I wanted to make sure I wasn't missing out on anything. So
the way I have it is pretty much what people do? (as far as mouse
dragged information goes)
- (void) mouseDragged:(NSEvent*)event
{
NSPoint eventLocation = [event locationInWindow];
NSPoint center = [self convertPoint:eventLocation fromView:nil];
m_controller->left_mouse_dragged(center.x, center.y);
}
-graham
On May 27, 2008, at 10:48 PM, Jens Alfke wrote:
On 27 May '08, at 8:38 PM, Graham Reitz wrote:
Do folks somehow get the direction of the drag, size of the
rectangle, starting x,y, and etc.?
IIRC, there are NSEvent properties that give you the x and y deltas
since the last mouseDragged event (called something like -dx or -
deltaX...)
More commonly, I store the coordinates of the mouse-down in an
NSPoint instance variable and use that while handling mouseDragged
and mouseUp. This is sort of an abuse of scope, because that
information is specific to the drag operation, not part of the
object's state, but it's safe because, as we all know, it's
intuitively obvious that there can only be one mouse drag happening
at a time.
A cleaner design would be to create some kind of "MouseTracker"
object to store the state, and instantiate one on mouse-down and
pass the other mouse events to it. But I've never found it worth the
trouble to make one.
—Jens
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden