1

I am developing a Cocoa application.

I have a NSOutlineView displaying custom cells ( cells inherits from NSTextFieldCell). The problem I am facing to is that the cell text is only displayed on one line... how can I have a multiline textField ???

Thanks for reading ;)

ayorosmage
  • 1,607
  • 1
  • 15
  • 21

1 Answers1

3
  1. Configure your table column's dataCell to wrap instead of scroll with -[NSCell setWraps:]
  2. Implement -[NSObject outlineView: heightOfRowByItem:] in your outline view delegate.
  3. Use -[NSCell cellSizeForBounds:] to find the height of the cell for a specific width. For cellSizeForBounds:, you can pass a really tall rectangle that's the width of your column, and it will return a smaller rectangle that is the right height for the text to fit in that width.
Jon Hess
  • 14,237
  • 1
  • 47
  • 51
  • Hey Jon, can you please post an example of your Step 3. Thanks a lot. – Peter Shaw Feb 13 '15 at 23:31
  • If you wanted to know how tall your text was for a width of 100, you would invoke something like this: [cell cellSizeForBounds:NSMakeRect(0, 0, 100, 10000)].height – Jon Hess Feb 18 '15 at 17:52