NSTextView does word-wrap by default. How can I disable this? I'm making a JSON code viewer, so I have to disable this.
+1
A:
I got solution from: http://lists.apple.com/archives/cocoa-dev/2008/May/msg02396.html
Copied code snippet here for reference purpose:
[[textView textContainer] setContainerSize:NSMakeSize(FLT_MAX, FLT_MAX)];
[[textView textContainer] setWidthTracksTextView:NO];
[textView setHorizontallyResizable:YES];
You have to set NSTextView's maximum width to very large number to make this work correctly. (Just copy maximum height) And enable horizontal scrolling of NSScrollView which is superview of the NSTextView. See these pictures:
Eonil
2010-07-04 09:51:33
A:
Easiest way is in Interface Builder, in the inspector just change the drop-down menu.
SeniorShizzle
2010-07-04 10:07:24
What's the box to uncheck for this?
Eonil
2010-07-04 10:11:38
Sorry, it's actually not a button, it's a drop-down menu. It says "Default Behavior" and you can select Scroll, which would fit your application well.
SeniorShizzle
2010-07-04 10:35:49
SeniorShizzle: There is no such pop-up menu for NSTextViews as of IB 3.2.1.
Peter Hosey
2010-07-04 15:16:13
Oh. Sorry I misread your post, I thought you said NSTextField in which case my answer would work. The above poster's method should work fine then, if not you might either try messing with the "Horizontal Line Scroll" field, (I'm not sure, but it sounds promising) or if your application would allow it just use an NSTextField it's my preferred choice.
SeniorShizzle
2010-07-04 18:15:57
A text field wouldn't work very well for a code view, as a text field is primarily for single-line values. (As an aside, I actually do let my editors wrap my code.)
Peter Hosey
2010-07-04 20:03:35
NSTextField was not suitable for my purpose. There're pretty many limitations to display very large amount of text.
Eonil
2010-07-05 04:02:46