• 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
[SOLVED] Re: Remembering the state of an NSScrollView?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SOLVED] Re: Remembering the state of an NSScrollView?


  • Subject: [SOLVED] Re: Remembering the state of an NSScrollView?
  • From: Nick Zitzmann <email@hidden>
  • Date: Fri, 9 Feb 2007 14:27:23 -0700


On Feb 9, 2007, at 9:21 AM, Dominik Pich wrote:

b) you might want to save the visibleRect's origin?!

Dont know if its any goood but worth a try, I'd say :)

Someone off-list gave me the hint that lead me to a solution. Just in case anyone bumps into this in the archives, this appears to work:


@implementation NSView (Normalization)

- (NSRect)normalizedVisibleRect
{
NSRect visibleRect = [self visibleRect];
NSRect bounds = [self bounds];
NSRect normalizedVisibleRect;

normalizedVisibleRect.origin.x = (visibleRect.origin.x- bounds.origin.x)/bounds.size.width;
normalizedVisibleRect.size.width = visibleRect.size.width/ bounds.size.width;
normalizedVisibleRect.origin.y = (visibleRect.origin.y- bounds.origin.y)/bounds.size.height;
normalizedVisibleRect.size.height = visibleRect.size.height/ bounds.size.height;

return normalizedVisibleRect;
}



- (void)scrollNormalizedRectToVisible:(NSRect)normalizedVisibleRect
{
NSRect bounds = [self bounds];
NSRect visibleRect;

visibleRect.origin.x = bounds.origin.x +bounds.size.width*normalizedVisibleRect.origin.x;
visibleRect.size.width = normalizedVisibleRect.size.width*bounds.size.width;
visibleRect.origin.y = bounds.origin.y +bounds.size.height*normalizedVisibleRect.origin.y;
visibleRect.size.height = normalizedVisibleRect.size.height*bounds.size.height;

[self scrollRectToVisible:visibleRect];
}


@end

Then we can archive the result of -normalizedVisibleRect, and unarchive it later and plug it into -scrollNormalizedRectToVisible:, and everything works.

Nick Zitzmann
<http://www.chronosnet.com/>


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


References: 
 >Remembering the state of an NSScrollView? (From: Nick Zitzmann <email@hidden>)
 >Re: Remembering the state of an NSScrollView? (From: Dominik Pich <email@hidden>)

  • Prev by Date: Re: LDAP Kerberos support...
  • Next by Date: Re: iTunes-like behaviour of NSButton with NSAlternateKeyMask
  • Previous by thread: Re: Remembering the state of an NSScrollView?
  • Next by thread: how to use the "small icon menu" in the main menu bar?
  • Index(es):
    • Date
    • Thread