Re: Dragging Around A NSScrollView
Re: Dragging Around A NSScrollView
- Subject: Re: Dragging Around A NSScrollView
- From: Allan Odgaard <email@hidden>
- Date: Sun, 28 Mar 2004 09:23:52 +0200
On 28. Mar 2004, at 3:50, Seth Willits wrote:
When the mouse is over the background and not inside the whole
rectangle thing, it would be an openHandCursor and let you drag the
view around (by drag I mean dragging left and right would make the
bottom scrollbar scroll, dragging up and down would make the right
scrollbar scroll). When the mouse is inside any of the objects being
drawn on top of the background it would be an arrow cursor.
Generally you do rectangle based cursor changes by using NSView's
addCursorRect:cursor:
while (keepOn) {
theEvent = [[self window] nextEventMatchingMask: NSLeftMouseUpMask |
NSLeftMouseDraggedMask];
I do not see the need to make this a local loop. Instead I would
overload mouseDown:, mouseDragged: and mouseUp:.
[mScrollView setDocumentCursor:[NSCursor closedHandCursor]];
Instead send 'set' or 'push' to the cursor, since this is just a
temporary cursor.
I haven't begun to move the view around yet because I can't event get
the cursor to change. So the question is, how do I get the cursor to
change, and how would I make the scrollbars scroll?
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.
Haven't tried it, but I think that's the easiest solution.
** Cocoa FAQ: <
http://www.alastairs-place.net/cocoa/faq.txt> **
_______________________________________________
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.