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 671681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:24:02+00:00 2026-05-14T00:24:02+00:00

What would be the easiest or recommended way for making an NSOutlineView indent multiple

  • 0

What would be the easiest or recommended way for making an NSOutlineView indent multiple columns? By default, it only indents the outline column; and as far as I know there is no built-in support for making it indent other columns.

I have an NSOutlineView which shows a comparison between two sets of hierarchical data. For visual appeal, if some item in the outline column is indented, I’d like to indent the item on the same row in another column by the same indentation amount. (There’s also a third column which shows the result of comparing the two items, this column should never be indented.)

Can this only be achieved by subclassing NSOutlineView? And what would need to be overridden in the subclass? Or is there an easier way to get it to indent multiple columns?

  • 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-14T00:24:02+00:00Added an answer on May 14, 2026 at 12:24 am

    Turns out to be easier than I expected. Here’s a sketch of the solution. To indent a column other than the outline column in an NSOutlineView, you can:

    • Create a subclass of the NSCell class you will be using for that column, say MYIndentedCell
    • Add an instance variable indentation to MYIndentedCell, and provide an accessor and mutator method for it
    • Override at least drawWithFrame:inView: in MYIndentedCell to:
         - (void) drawWithFrame: (NSRect) frame inView: (NSView*) view
         {
           NSRect newFrame = frame;
           newFrame.origin.x += indentation;
           newFrame.size.width -= indentation;
           [super drawWithFrame: newFrame inView: view];
         }
    
    • You will need to also override editWithFrame:inView and selectWithFrame:inView: similar to the above if the column will be editable
    • Override cellSize to:
         - (NSSize) cellSize
         {
           NSSize cellSize = [super cellSize];
           cellSize.width += indentation;
           return cellSize;
         }
    
    • Finally, getting the indentation in the column to follow the indentation of the NSOutlineView’s outline column will be handled by the outline view’s delegate. The delegate needs to implement the following:
         - (void) outlineView: (NSOutlineView *) view
                  willDisplayCell: (id) cell
                  forTableColumn: (NSTableColumn *) column
                  item: (id) item
         {
           if (column == theColumnToBeIndented) {
             [cell setIndentation:
                      [view indentationPerLevel] * [view levelForItem: item]];
           }
         }
    

    If you’re still having trouble getting it to work, you might want to take a look at ImageAndTextCell.m in Apple’s SourceView sample code which I found very helpful in figuring out how to do the above.

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

Sidebar

Related Questions

What would be the easiest way of using commands in the code to programatically
What would be the easiest way to have the color of a text field
I would like to know what is the best, fastest and easiest way to
What's the easiest way to generate a bitmap using Python? Text support would be
I'm looking for the easiest and the most recommended way to upgrade mongodb version
Good afternoon I would just like to know the easiest way for standard Console
Something as simple as: $(#div).addClass(error).delay(1000).removeClass(error); doesn't seem to work. What would be the easiest
What is the easiest-to-code-in technology that would give me real time access to a
Would following the table below be the best way of determining the access type
I was thinking of cross platform support the easiest way, there were many answers,

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.