• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Dragging Around A NSScrollView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


References: 
 >Dragging Around A NSScrollView (From: Seth Willits <email@hidden>)
 >Re: Dragging Around A NSScrollView (From: Allan Odgaard <email@hidden>)

  • Prev by Date: Open NSSavePanel in windowDidLoad?
  • Next by Date: Re: Where did the window go?
  • Previous by thread: Re: Dragging Around A NSScrollView
  • Next by thread: RE: Dragging Around A NSScrollView
  • Index(es):
    • Date
    • Thread