Re: Consistent scroll-to-visible of text view?
Re: Consistent scroll-to-visible of text view?
- Subject: Re: Consistent scroll-to-visible of text view?
- From: Ashley Clark <email@hidden>
- Date: Tue, 16 Dec 2008 21:58:51 -0600
On Dec 16, 2008, at 12:46 PM, Randall Meadows wrote:
I have a table that contains representations of various types of
data. As a row is selected another view changes to show details of
that data. For instance, some display images and some display text
in an NSTextView.
As I change from one row to the next, I populate the detail display
area with the relevant detail data. When I populate the text view,
it was always displaying the text view scrolled to the bottom,
presumably because that's where the insert point was left after I
inserted the text into the view.
Fine, I'll just stick [notesView scrollRangeToVisible:NSMakeRange(0,
0)]; in there, after I insert the text, before it gets displayed.
BOOL wasEditable = [notesView isEditable];
[notesView setEditable:YES];
[notesView selectAll:nil];
[notesView insertText:textToDisplay];
[notesView setEditable:wasEditable];
[notesView scrollRangeToVisible:NSMakeRange(0, 0)];
Well, now it alternates between being scrolled to the beginning of
the text and being scrolled to the end of the text on subsequent row
selections. It'll keep alternating as long as I keep changing the
selection. And, it seems to be sensitive to manual scrolling as
well: If, when it's scrolled to the top, I manually scroll it to the
bottom, change the selection and then come back, the alternating now
picks up with it being scrolled to the top again, in an opposite
phase.
What am I missing to always start the display of this newly-unhidden
text view with it scrolled to the top such that the start of the
text is always visible?
Try setting the selected range also. For instance, [notesView
setSelectedRange:NSMakeRange(0, 0)], that sets the position of the
insertion point and should keep it scrolled to the top I think.
Ashley
_______________________________________________
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