Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > More dynamic horizontal NSTextView scrolling

More dynamic horizontal NSTextView scrolling
Thread Tools
Mac Elite
Join Date: Sep 2000
Location: Eagan, MN
Status: Offline
Reply With Quote
Mar 31, 2001, 04:09 PM
 
I put a NSTextView object into a NSScrollView to get both horizontal and vertical scrollbars. But, the only way I've found to make the horizontal scrollbar work is by setting the minimum width of NSTextView to a size greater than NScrollView. This is OK, but the horizontal scroll range is stuck the same all the time.

Is there a way to make the horizontal scrollbar to work mroe dynamically (like the vertical one)?
     
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status: Offline
Reply With Quote
Mar 31, 2001, 05:27 PM
 
- (void)setHasHorizontalScrollerBOOL)flag in NSScrollView is what you want.

[Edit]
oops: I wasn't paying full attention. If you want the thing to resize horizontally until the user hits return there are two things that you could try. I know that in some text classes there is a nowrap option. I have used it in NSTextFieldCell but I have never tried in NSTextView. If there is no equivalent method in NSTextView then you can make a delegate to respond to every key press and set the frame of the NSTextView accordingly. Basically the scrollbars on the NSScrollView are only going to appear if the view that they contain is larger than the scroll View. It isn't something that you set with the scroll view. how much it'll scroll, if the scrollbar is visible is simply a function of the frame of what the view contains. Note that the bounds rect is the visible part of your NSTextView while the frame rect would be the entire view.

[This message has been edited by Dalgo (edited 03-31-2001).]
     
Mac Elite
Join Date: Sep 2000
Location: Eagan, MN
Status: Offline
Reply With Quote
Apr 1, 2001, 12:53 AM
 
Thanks for the reply, Dalgo. The solution ended up being simple. I just had to turn off width tracking on my NSTextView's NSTextContainer. If anyone else is interested, here's the code I'm using to initialize the objects (scrollView is an NSScrollView and editBox is an NSTextView):

[scrollView setHasVerticalScroller:YES];
[scrollView setHasHorizontalScroller:YES];
[scrollView setDocumentViewNSView *)editBox];

[[editBox textContainer] setContainerSize:NSMakeSize(500000.0,500000.0)];
[[editBox textContainer] setWidthTracksTextView:NO];
[[editBox textContainer] setHeightTracksTextView:NO];
[editBox setHorizontallyResizable:YES];
[editBox setVerticallyResizable:YES];
[editBox setMaxSize:NSMakeSize(500000.0,500000.0)];

------------------
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 11:14 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2