Re: Dragging Around A NSScrollView
Re: Dragging Around A NSScrollView
- Subject: Re: Dragging Around A NSScrollView
- From: Seth Willits <email@hidden>
- Date: Sun, 28 Mar 2004 00:44:39 -0800
On Mar 27, 2004, at 11:23 PM, Allan Odgaard wrote:
For the latter, in mouseDown: save the visible bounds ([self
visibleBounds]) and the event location (locationInWindow). Then in
mouseDragged: you create a new rectangle from the visible bounds,
offsetting it with the distance between the location from mouseDown:
and the current location -- then send [self
scrollRectToVisible:newRect] to make the scrollbars move.
Jim sent me some code to handle the dragging and the cursor pretty
easily. The scrolling part was pretty darn simple:
- (void)mouseDragged:(NSEvent *)theEvent
{
[self scrollPoint:
NSMakePoint(startOrigin.x - ([theEvent locationInWindow].x -
startPt.x),
startOrigin.y - ([theEvent locationInWindow].y -
startPt.y))];
}
Thanks for the help.
Seth Willits
------------------------------------------------------------------------
---
President and Head Developer of Freak Software -
http://www.freaksw.com
REALbasic Guru at ResExcellence -
http://www.resexcellence.com/realbasic
Webmaster for REALbasic Game Central -
http://www.freaksw.com/rbgames
"The problem of defense is how far you can go without destroying from
within what you are trying to defend from without."
-- Dwight D. Eisenhower
------------------------------------------------------------------------
---
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.