• 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: "Eric Huffman" <email@hidden>
  • Date: Sun, 28 Mar 2004 15:52:59 -0600

I have a situation where I use an approach similar to that below.

However, I was wondering if anyone could describe the pros and cons of
using the "mouse-tracking-loop-within mouseDown:" vs. the
"save-state-for mouseDown: and mouseDragged:" approaches. Not being a
cocoa expert, I am never exactly sure which approach to take. The later
approach gives the app kit control over handling the various events,
timers, etc..., that occur during the drag and that seems generally like
a "good thing".

- Eric

>> 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
_______________________________________________
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.


  • Follow-Ups:
    • Re: Dragging Around A NSScrollView
      • From: Seth Willits <email@hidden>
  • Prev by Date: Re: classic floating window behavior?
  • Next by Date: Re: NSURL and lingering FTP processes
  • Previous by thread: Re: Dragging Around A NSScrollView
  • Next by thread: Re: Dragging Around A NSScrollView
  • Index(es):
    • Date
    • Thread