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

  • SEARCH
  • Home
  • 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 805357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:04:11+00:00 2026-05-15T00:04:11+00:00

I have an NSTableView that has 2 columns, one for an icon and the

  • 0

I have an NSTableView that has 2 columns, one for an icon and the other for two lines of text. In the second column, the text column, I have some larger text that is for the name of an item. Then I have a new line and some smaller text that describes the state of the item.

When the name becomes so large that it doesn’t fit on one line it wraps (or when you shrink the window down so small that it causes the names to not fit on a single line).

row1===============
| image |  some name   |
| image |   idle               |
row2================
| image |  some name really long name   | <- this gets wrapped pushing ‘idle’ out of the view
| image |   idle               |
===================

My question is, how could I keep the text from wrapping and just have the NSTableView display a horizontal scroll-bar once the name is too large to fit?

  • 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-15T00:04:11+00:00Added an answer on May 15, 2026 at 12:04 am

    Scrolling in Cocoa is implemented with the NSScrollView which is a view instead of a cell so if you really want to implement horizontal scrolling for table view cells I think you’d have to subclass the whole NSTableView and implement the feature there. My suggestion (without knowing the specifics of your situation, of course) is that you don’t do that, though, since it’s nonstandard behaviour and would probably entail quite a bit of work.

    Truncate Instead of Wrap

    If you’re using a standard NSTextFieldCell, just select “Truncates” for its layout value in IB instead of “Wraps”.

    If you have a custom NSCell where you’re doing your own drawing (I assume this is the case here), you should create an NSParagraphStyle, set its line break mode, add it as a value for the NSParagraphStyleAttributeName key in the NSAttributedString‘s text attributes dictionary.

    An example:

    NSMutableParagraphStyle *paragraphStyle = [[[NSMutableParagraphStyle alloc] init] autorelease];
    [paragraphStyle setLineBreakMode:NSLineBreakByTruncatingTail];
    [attributedStr
     addAttribute:NSParagraphStyleAttributeName
     value:paragraphStyle
     range:NSMakeRange(0,[attributedStr length])];
    

    Cell Expansion Frames

    If you don’t want to wrap your lines of text in the table view cells, the standard method of allowing the user to see the whole text is to use cell expansion frames which are enabled by default:

    Cell expansion can occur when the mouse hovers over the specified cell and the cell contents are unable to be fully displayed within the cell.

    If they’re not working for some reason and you’re using a custom NSCell subclass, make sure you implement -drawWithExpansionFrame:inView: and -expansionFrameWithFrame:inView: in your cell. Also make sure you’re not returning NO in your NSTableViewDelegate for -tableView:shouldShowCellExpansionForTableColumn:row: (if you have one).

    Adjust Width of Whole Table View?

    If what you want to do is to adjust the width of a specific column (and thus the whole table view, possibly causing the enclosing scroll view’s horizontal scroll bar to appear) such that the text its cells contain would never be truncated or wrapped, you can probably do that in your NSTableViewDelegate, for example, by calling -cellSize for each row’s cell in that column and resizing the column to the largest value (you’ll want to only do this when the values change, of course).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view-based NSTableView that usually has one column in it. However, at
I have an NSTableView that has one column of editable fields. Cell editing works
I have an NSTableView that contains 2 different Columns - one is an NSImageCell
I have an NSTableView with two columns and a data source that fills it
I have an NSCrollView that contains an NSTableView. It has 3 columns and 4
I have a NSTableView that contains a NSButtonCell in one of the columns. I
I have an NSTableView that contains a few columns that are populated with data.
I have NSTableView with two columns, and i wanna fill them entries from SQLite
I have an array of images, and two nib files. One nib file has
In my application, I have a NSWindow that has a NSTableView object and a

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.