Re: NSTextView & Horizontal Scrollbar bug
Re: NSTextView & Horizontal Scrollbar bug
- Subject: Re: NSTextView & Horizontal Scrollbar bug
- From: Ross Carter <email@hidden>
- Date: Sun, 06 Dec 2009 19:04:01 -0500
On Dec 5, 2009, at 9:14 AM, Eric Gorr wrote:
> On Dec 4, 2009, at 12:30 PM, Ross Carter wrote:
>
>> On Dec 4, 2009, at 9:29 AM, Eric Gorr wrote:
>>
>>> I've got a sample application at http://ericgorr.net/cocoadev/TextViewNoWrap.zip which demonstrates the problem I am seeing.
>>>
>>> Basically, there is just a text view on a window with a horizontal scrollbar which appears only when needed.
>>>
>>> I have set this text view up based on the instructions found in the "Text System User Interface Layer Programming Guide for Cocoa" (page 18 - Setting Up a Horizontal Scroll Bar).
>>>
>>> After ~77 characters or so, the horizontal scrollbar stops scrolling and I can't make any of the text beyond that visible in my view.
>>>
>>> This looks like a bug to me and one that is likely already known.
>>>
>>> Are there any known or suggested workarounds?
>>
>> In IB you have set the maximum width of the text view to 478, so that is the limit you are running up against.
>
> What is the suggested or common solution?
>
> I noticed, for example, the the height of the text view is set to 1,000,000 pixels and that if I set it to 478 a similar problem occurs.
>
> So, this implies one solution would be to simply set the width of the view to the arbitrarily large value of 1,000,000 pixels as well.
>
> So, the question becomes, why not just set it to FLT_MAX (or should it be CGFloat_Max?) - the same size as the text container?
>
> At this size, the scrollbars continue to work as one would expect. What I don't know is if there would be unexpected side effects or problems using FLT_MAX.
>
> By using FLT_MAX, and the same is likely true of 1,000,000 pixels, there would not seem to be a practical reason to worry about calculating how wide the text view needs to be to be able to scroll to all of the text. I can just set it once and forget about it. Would you agree?
It's hard to say what is best in general, but IMHO there ought to be a practical limit to the width. I cannot imagine why anyone would want to keep scrolling and scrolling to the right to read all of one line of text, and then go back all the way to the left and start scrolling again to read the next line. The requirements of the particular application might call for a very wide text view, but at some point it is going to become too difficult to scroll without annoyance.
For height, FLT_MAX is convenient because the vertical scroll is determined by the size of the text content, and the text system will use only as much height as necessary. For width, FLT_MAX is not so convenient, because width is determined by the longest line, and if a few lines are significantly longer than others, then most of the scrollview area will be empty white space. OTOH, if all lines are same width (e.g., monospaced font showing results of a SQL query), then it might make sense to set the width to a large value. It just depends on what text you are presenting and how the user will want to view it.
-Ross
_______________________________________________
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