Re: Problems manually scrolling a view using mouseDown:
Re: Problems manually scrolling a view using mouseDown:
- Subject: Re: Problems manually scrolling a view using mouseDown:
- From: glenn andreas <email@hidden>
- Date: Mon, 24 Jan 2005 08:53:47 -0600
On Jan 23, 2005, at 11:28 PM, mmalcolm crawford wrote:
On Jan 23, 2005, at 9:15 PM, Matt Neuburg wrote:
(2) You exit the event loop prematurely, instead of generating your
own
event loop during the drag, as explained in the helpful document
"Handling
Mouse Events in Views".
[...]
- (void) mouseDown: (NSEvent*) e {
NSScrollView* sv = [self enclosingScrollView];
NSClipView* cv = [sv contentView];
[[NSCursor openHandCursor] push];
clickPoint = [e locationInWindow];
originalOrigin = [cv bounds].origin;
{
BOOL keepOn = YES;
while (keepOn) {
NSEvent* theEvent = [[self window] nextEventMatchingMask:
NSLeftMouseUpMask | NSLeftMouseDraggedMask];
That document is, unfortunately, misleading (and a bug has been
filed). You should not set up your own "mini event loop" in this way.
You should instead capture the relevant information in mouseDown: and
then deal with updates in mouseMoved: and mouseUp:.
Equally annoying is that neither approach gets auto-scrolling quite
right, since neither get events when the user doesn't move the mouse
(so if they click in your view, and then drag off the view, you only
autoscroll if they key moving the mouse). You'll also need to install
a timer to handle autoscrolling when the mouse is down but not moving -
not all that hard, just annoying to have to implement every time you
need this.
Just one of those little "edge case" behaviors that everybody has to
implement (or at least should), even though Cocoa does almost
everything for you but not quite.
Glenn Andreas email@hidden
<http://www.gandreas.com/> oh my!
Mad, Bad, and Dangerous to Know
_______________________________________________
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