• 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
Problem centering inside a scrollview
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem centering inside a scrollview


  • Subject: Problem centering inside a scrollview
  • From: Matt Ball <email@hidden>
  • Date: Sun, 24 Jul 2005 15:00:44 -0400

I've gotten it so that my scrollView's contentView gets centered
inside of the scrollview. However, I have a custom cursor set for my
scrollView's documentView. With my centering code in place, the cursor
stays the normal arrow until I get to the centered view (as expected).
However, when I move the mouse below or to the right of my view, the
cursor stays changed instead of reverting to the arrow. Here's the
code that is called whenever the scrollview is resized:

- (void)centerCanvas {
	NSRect newBounds = [[self contentView] bounds];
	NSRect newFrame = [[self contentView] frame];
	if([self frame].size.width > newFrame.size.width || [self
frame].size.height > newFrame.size.height) {
		if((newBounds.size.width - [[self documentView] frame].size.width)/2 > 0)
			newFrame.origin.x = (newBounds.size.width - [[self documentView]
frame].size.width)/2;
		if((newBounds.size.height - [[self documentView] frame].size.height)/2 > 0)
			newFrame.origin.y = (newBounds.size.height - [[self documentView]
frame].size.height)/2;

		[[self contentView] setFrame:newFrame];
		[self setNeedsDisplay:YES];
	}
}

I added in the following lines, and the cursor problem was fixed:

		newFrame.size.width = [[self documentView] frame].size.width;
		newFrame.size.height = [[self documentView] frame].size.height;

However, with that code in place, the scroll bars do not appear when
they should. So, I know the problem is that the clipview is only
having its origin moved, and its size isn't changing. Does anyone know
how I can fix this?

- Matt Ball
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: NSString to char[]
  • Next by Date: Re: Converting between NSData and NSString losslessly
  • Previous by thread: Re: Interpreting Documentation: Is a nil argument OK?
  • Next by thread: Change cursor when dragging in NSTableView?
  • Index(es):
    • Date
    • Thread