Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 893057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:09:29+00:00 2026-05-15T14:09:29+00:00

NSTextView does word-wrap by default. How can I disable this? I’m making a JSON

  • 0

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 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T14:09:30+00:00Added an answer on May 15, 2026 at 2:09 pm

    First, this document explains why and how — https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/TextStorageLayer/Tasks/TrackingSize.html#//apple_ref/doc/uid/20000927-CJBBIAAF

    I got solution from: http://lists.apple.com/archives/cocoa-dev/2008/May/msg02396.html

    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:

    http://www.flickr.com/photos/47601728@N06/4759470529/

    alt text

    http://www.flickr.com/photos/47601728@N06/4759470533/

    alt text

    Update

    I discovered my old sample code was insufficient to make it fully work correctly. (because of SDK version?)
    Also
    Here’s my full source code snippet which disables word-wrap in OSX 10.8 SDK.

    [self setMaxSize:CGSizeMake(FLT_MAX, FLT_MAX)];    
    [self setHorizontallyResizable:YES];               
    [[self textContainer] setWidthTracksTextView:NO];  
    [[self textContainer] setContainerSize:CGSizeMake(FLT_MAX, FLT_MAX)];  
    

    Update 2

    Now Apple is providing an official guide to create NSTextView correctly. I hope this helps.

    Update 3

    I posted an example project on Github. See this page for specific implementation: https://github.com/Eonil/CocoaProgrammaticHowtoCollection/blob/master/ComponentUsages/TextView/ExampleApplicationController.swift?ts=4

    Here’s a code snippet from the sample project.

    if wordWrap {
        /// Matching width is also important here.
        let sz = scrollView.contentSize
        textView.frame = CGRect(x: 0, y: 0, width: sz.width, height: 0)
        textView.textContainer?.containerSize = CGSize(width: sz.width, height: CGFloat.greatestFiniteMagnitude)
        textView.textContainer?.widthTracksTextView = true
    }
    else {
        textView.textContainer?.widthTracksTextView = false
        textView.textContainer?.containerSize = CGSize(width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude)
    }
    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 496k
  • Answers 496k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try this: var clone = $("#table-1 tr:last").clone().find('input').val('').end(); .clone() the last… May 16, 2026 at 11:47 am
  • Editorial Team
    Editorial Team added an answer Have a go with this PHPOCR class. May 16, 2026 at 11:47 am
  • Editorial Team
    Editorial Team added an answer Objects are not necessarily cleared from memory when you call… May 16, 2026 at 11:46 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a button that does something to the selected text in NSTextView. If
I am trying to override NSTextView - (void)complete:(id)sender method but I can't find any
I have a placeholder string, a space character, in an NSTextView that I want
I'm contemplating subclassing UIScrollView (the way UITextView does) to draw a fairly large amount
I want to add a data detector in an NSTextField / NSTextView like in
I am working on an app with an NSTextView. When I paste random bytes
Given an NSApp object (aka [NSApplication sharedApplication]), how can I get the currently active
I have an NSTextField that I would like to enable as-you-type spell checking. When
I have a custom NSTableView subclass filled with several custom NSTextFieldCell subclasses. I would
I have added the frameworks (MapKit and CoreLocation) by selecting the Frameworks folder, right

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.