• 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: pagingEnabled on NSScrollView?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pagingEnabled on NSScrollView?


  • Subject: Re: pagingEnabled on NSScrollView?
  • From: Leonardo <email@hidden>
  • Date: Fri, 17 Jun 2011 13:04:53 +0200
  • Thread-topic: pagingEnabled on NSScrollView?

Hi, thanks,
it works. But now I get a new trouble:
If I set setHasHorizontalScroller:NO, any scrollPoint: I call
programmatically is not seen by the next drag.
In details:

within the method endGestureWithEvent: I call
    NSLog(@"endGesture %@", NSStringFromPoint([mClipView bounds].origin));
    // and I get X = 50;

    [NSObject cancelPreviousPerformRequestsWithTarget:self
            selector:@selector(scrollToPageNum:) object:nil];
    // now we go and adjust the scroll to 100.
    [self performSelector:@selector(scrollToPageNum:) withObject:NumI(page)
    afterDelay:0];


within the scrollToPageNum: I programmatically scroll the clipView to the
X point = 100.
    [mDocView scrollPoint:newPoint];
    [self reflectScrolledClipView:mClipView];
    [self display];

Now I can see the page well positioned at X = 100
Also, if I check with
    NSLog(@"scrollToPage %@", NSStringFromPoint([mClipView bounds].origin));
everything looks ok. I get X = 100;

Now If a drag again on the trackpad, the clipView moves suddenly to the X=50
then I can drag the page. Wrong! When setHasHorizontalScroller:YES the error
doesn't occur.

What do I miss?


Regards
-- Leonardo


> Da: Quincey Morris <email@hidden>
> Data: Thu, 16 Jun 2011 16:17:53 -0700
> A: Leonardo <email@hidden>
> Cc: <email@hidden>
> Oggetto: Re: pagingEnabled on NSScrollView?
>
> On Jun 16, 2011, at 14:57, Leonardo wrote:
>
>> I would like to reach the same effect as UIScrollView.pagingEnabled, but on
>> an NSScrollView. Can that be done?
>>
>> If not, which technique should I use?
>> I thought to deal with NSAnimationContext to move the scrollView's document
>> with scrollPoint: when a scrolling ends (the finger stops dragging on the
>> track-pad). Am I on the right way?
>
> NSScrollView is not designed to have this behavior, so you'll have to do the
> work.
>
> The basic approach is to have (say) your window controller monitor the scroll
> view's clip view's frame- and bounds-changed notifications. When you receive
> these notifications, you examine the relationship between the "clip" view
> bounds and the "document" (i.e. enclosed) view frame, and adjust the
> relationship to align the two views however you want.
>
> To detect when scrolling "ends", you can use a well-known trick. When you see
> a notification, don't perform the scrolling adjustment immediately, but
> schedule it for "later" using 'performSelector: ... afterDelay: 0'. Since you
> don't want multiple deferred adjustments to get queued, you first cancel any
> pending ones with one of the 'cancelPrevious...' or 'cancelPerform...'
> methods, just before invoking 'performSelector:...'. That way, the last one
> "wins".
>
> If you want to have this adjustment animate, you should be able to use the
> appropriate view's animator or NSViewAnimation to move the document view
> frame.
>
> The only difficulty I can think of is if Lion's trackpad gesture-based
> scrolling itself has some animation built into it (e.g. an iOS-like "bounce").
> In that case you might have some trouble trying to integrate your animation
> with the built-in one.
>
> However, given that all of this is not expected Mac scroll view behavior,
> unless you have a *very* compelling need for it, I'd recommend you don't do
> it. NSScrollView responds to the Page Up and Page Down keys for paging. Why
> limit the user to where you think the page boundaries are?
>
>


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: pagingEnabled on NSScrollView?
      • From: Quincey Morris <email@hidden>
References: 
 >Re: pagingEnabled on NSScrollView? (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: NSString accessing characters
  • Next by Date: Re: NSString accessing characters
  • Previous by thread: Re: pagingEnabled on NSScrollView?
  • Next by thread: Re: pagingEnabled on NSScrollView?
  • Index(es):
    • Date
    • Thread