• 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
scrolling an NSText to the bottom
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

scrolling an NSText to the bottom


  • Subject: scrolling an NSText to the bottom
  • From: "Simson Garfinkel" <email@hidden>
  • Date: Thu, 15 Nov 2001 09:15:04 -0500

NeXTSTEP Text objects supported scrollToSel, but that functionality appears
to be gone from the new NSText and NSTextView classes.

I am attempting to scroll an NSTextView object to the bottom. Here is my
sample code. It doesn't work:

- (IBAction)addLines:(id)sender
{
int i;
float height;

for(i=0;i<100;i++){
NSString *str = [NSString stringWithFormat:@"Here is another line,
#%d\n",i];
int len = [[theText string] length];

[theText
replaceCharactersInRange:NSMakeRange(len,0)
withString:str];
}

if([theText isFlipped]){
NSLog(@"theText is flipped");
}

/* Now scroll to see the last line */
height = [theText frame].size.height;
NSLog(@"Attempting to scroll to 0,%f in frame",height);
if([theText scrollRectToVisible:NSMakeRect(0,height-1,1,1)]){
NSLog(@"Scrolling was performed");
}
}

@end

You'll note that this code verifies that theText is flipped (so the
lower-left is 0,height-1, and not 0,0). But no scrolling happens. Anybody
have a clue?


  • Follow-Ups:
    • Re: scrolling an NSText to the bottom
      • From: Ben Hines <email@hidden>
    • Re: scrolling an NSText to the bottom
      • From: Eric Peyton <email@hidden>
  • Prev by Date: NSWindow / PB possible bugs
  • Next by Date: sub-projects in ProjectBuilder
  • Previous by thread: Re: NSWindow / PB possible bugs
  • Next by thread: Re: scrolling an NSText to the bottom
  • Index(es):
    • Date
    • Thread