Problems manually scrolling a view using mouseDown:
Problems manually scrolling a view using mouseDown:
- Subject: Problems manually scrolling a view using mouseDown:
- From: John Fox <email@hidden>
- Date: Fri, 21 Jan 2005 20:02:07 -0800
Hello:
I have an NSImageView subclass that is contained within an NSScrollView. I'm trying to make it possible to scroll the view by dragging the mouse in the view, but I've run into some problems.
This is what I've tried so far, and it doesn't quite work right. I have these problems:
1) When dragging, my open hand cursor reverts to the arrow cursor.
2) The scrolling doesn't seem to track evenly with the mouse: I'm not sure if I'm translating the mouse location correctly.
Here's the code I have so far. Could some kind soul guide me?
- (void)mouseDown:(NSEvent *)theEvent
{
// Give the user a hand
[[NSCursor openHandCursor] set];
}
(void)mouseDragged:(NSEvent *)theEvent
{
NSPoint myPoint = [self convertPoint:[theEvent locationInWindow] fromView:nil];
[self scrollPoint: myPoint
];
[self setNeedsDisplay:YES];
}
- (void)mouseUp:(NSEvent *)theEvent
{
// Back to our standard arrow cursor
[[NSCursor arrowCursor] set];
}
Many thanks,
John
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden