• 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: scroll view & drop-n-drag
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: scroll view & drop-n-drag


  • Subject: Re: scroll view & drop-n-drag
  • From: Matt Gemmell <email@hidden>
  • Date: Sat, 21 Jun 2003 09:40:52 +0100

On 21/6/03 at 6:03 am, Anthony Arthur said:

> Does anyone know how to make a scroll view scroll the hidden document
> view into view as the drag event goes outside the border of the scroll
> view? Is there some mechanism built in to do this? The behavior
> should be that the scroll speed is directly related to how far beyond
> the bounds the drag event goes--the further out the drag, the faster
> the document scrolls into view, and the closer the slower.

You can achieve the basic functionality (scrolling when a drag event
moves outwith the scrollview), by calling -[NSView autoscroll:] with the
relevant mouseDragged event (you'd do this by overriding mouseDragged:
in your NSView subclass which is the documentView of your scrollview).
It returns a BOOL to indicate whether any scrolling actually occurred.

Not sure how that will work with respect to varying speed; autoscroll
can be quite jerky at the best of times. For smoother scrolling and
finer control, you could note the mouseDown point and then perform some
calculations whenever you receive a mouseDragged event; you could then
use -[NSView scrollToPoint:] and the other related methods to perform
precision scrolling.

That's what I did when making up a simple NSImageView subclass which
supports grab-scrolling (though it scrolls at a constant speed; not
proportionally to the distance.) It's here:

<http://www.scotlandsoftware.com/ftp/source/grabscroll.tgz>

For proportional-speed scrolling, you could probably whip something up
by using a timer, instantiated in the mouseDown: handler and making use
of the locationInWindow value of successive mouseDragged events.

Cheers,
-Matt

--
Matt Gemmell
Scotland Software
http://www.scotlandsoftware.com/
_______________________________________________
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: 
 >scroll view & drop-n-drag (From: Anthony Arthur <email@hidden>)

  • Prev by Date: Re: Opening Finder window from another app
  • Next by Date: Re: Opening Finder window from another app
  • Previous by thread: scroll view & drop-n-drag
  • Next by thread: Re: scroll view & drop-n-drag
  • Index(es):
    • Date
    • Thread