Re: How to stop NSScrollView from scrolling to top when horizontally resizing contained NSTextView?
Re: How to stop NSScrollView from scrolling to top when horizontally resizing contained NSTextView?
- Subject: Re: How to stop NSScrollView from scrolling to top when horizontally resizing contained NSTextView?
- From: Lyndsey Ferguson <email@hidden>
- Date: Tue, 17 Nov 2009 17:51:20 -0500
On Tue, Nov 17, 2009 at 11:28 AM, Ross Carter <email@hidden> wrote:
> On Nov 16, 2009, at 4:33 PM, Lyndsey Ferguson wrote:
> I'm not sure exactly what you are trying to do, but it looks to me like you might be on the wrong track. Again, forgive me if I have misunderstood, which I often do, but I see these problems:
Hi Ross,
Fundamentally, I want to:
1. Display lines of text that don't wrap in my NSTextView.
2. Display a horizontal scrollbar.
3. Make sure that the width of the NSTextView is appropriately wide
for that line of text so that:
3.1 The user can scroll the width of the longest line of text and no more.
3.2 The scrollbar thumb is representative of that width.
The samples I found online to enable horizontal scrolling set the
width of NSTextContainer and NSTextView to the FLT_MAX, which is not
what I want to do as that invalidates my 3rd requirement (above).
http://lists.apple.com/archives/cocoa-dev/2002/Feb/msg01845.html
> You are using two different systems to determine width. After the text view's layout manager has already completed layout, you are calling the NSString method -sizeWithAttributes:, which uses a different layout system to layout and measure the text. The information you need can be gleaned from the text view's layout manager, perhaps with -lineFragmentUsedRectForGlyphAtIndex:effectiveRange:withoutAdditionalLayout:. In effect, you are laying out the text twice, using different systems that might well produce different results.
I did try using lineFragmentX calls to try and get the width of the
line of text (but failed as the lines of text were wrapped), but I had
not used the call that you mentioned. I will try it out.
>there are other differences that can crop up too, such as whether the 2 layout systems use the same typesetter compatibility setting.
Okay.
> Finally, this behavior does not sound like something that I, as a user, would want. I'm accustomed to exactly two kinds of layout: text with an infinite width, i.e. no line wrapping, and text with a fixed width, i.e. line wrapping that occurs at a certain width. I don't think I could get used to a layout system where the width varies as I type.
Perhaps I'm misunderstanding, but this seems to be exactly how Xcode's
text editor window works.
Thanks for you suggestions, I'll let the list know how it works for me.
Cheers,
Lyndsey
_______________________________________________
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