Using -scrollRectToVisible: in NSTextView
Using -scrollRectToVisible: in NSTextView
- Subject: Using -scrollRectToVisible: in NSTextView
- From: Jeremy Dronfield <email@hidden>
- Date: Tue, 6 Jul 2004 16:12:20 +0100
Are there any known issues with sending -scrollRectToVisible to
NSTextView (or subclasses)?
I'm trying to get my text view to remember the visible rect for the
last text file viewed, so that it can scroll back to that place when
the same file is next loaded. I'm doing this:
//load the text into the text view
[[textView textStorage] replaceCharactersInRange:NSMakeRange(0,
[[textView textStorage] length]) withAttributedString:theText];
//retrieve the last visible rect for that particular text file
NSRect scrollRect = [self getRectForNextFile:file];
NSLog(@"%@", NSStringFromRect(scrollRect));
[textView scrollRectToVisible: scrollRect];
The log outputs a valid rect - along the lines of {0, 1254, 425, 645} -
but the scrolling behaviour is either erratic or non-existent. If the
previously viewed file was very short (i.e. no scroller showing), no
scrolling occurs when a long file loads, whereas when switching between
long files, scrolling does happen - though not always to the right
place.
I've also tried using -scrollPoint:, with exactly the same results.
Does anyone have any experience of this, and if so, could they offer
any advice?
Regards,
-Jeremy
_______________________________________________
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.