• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Drawing glitches in NSTableView with variable row hight (just like Console.app)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Drawing glitches in NSTableView with variable row hight (just like Console.app)


  • Subject: Re: Drawing glitches in NSTableView with variable row hight (just like Console.app)
  • From: Jens Alfke <email@hidden>
  • Date: Tue, 20 Apr 2010 17:03:32 -0700


On 2010 Apr 19, at 08:56, Marco Masser wrote:

I'm trying to implement a logging facility for an app ..., i.e. an NSTableView with varying row heights.
I found three different approaches to calculating the height for a given width, but they all seem to be very performance-hungry:
1) (my favorite) I set the message string on my message column's NSTextFieldCell directly and call -cellSizeForBounds:
2) Creating an NSAttributedString with the attributes of my cell, calculating its size and then using the string's total width and my column's width.
3) Using some code from the docs involving an NSTextStorage, NSLayoutManager, and an NSTextContainer.

I wouldn't do it this way (and I speak from past experience, having tried to do this once). You're using NSTableView for something it's not good at — updating layout on the fly as the width changes — and more importantly, you lose flexibility in the UI, like being able to select text in a natural way. If you just use NSTextView instead, the layout will work automatically, and selection of course works the way users expect.


The only problem with NSTextView would be if you have truly enormous amounts of text to log. In that case NSTableView wins. But then trying to do multi-line layout in the table view will bog down for the same reason it does in the text view. If you really need to handle millions of lines, you probably just shouldn't attempt to wrap them.

—Jens_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Drawing glitches in NSTableView with variable row hight (just like Console.app)
      • From: Jerry Krinock <email@hidden>
References: 
 >Drawing glitches in NSTableView with variable row hight (just like Console.app) (From: Marco Masser <email@hidden>)
 >Re: Drawing glitches in NSTableView with variable row hight (just like Console.app) (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: CoreData: updating property of fetched object and refetching
  • Next by Date: Why is compiler warning for +setKeys:triggerChangeNotificationsForDependentKey: ??
  • Previous by thread: Re: Drawing glitches in NSTableView with variable row hight (just like Console.app)
  • Next by thread: Re: Drawing glitches in NSTableView with variable row hight (just like Console.app)
  • Index(es):
    • Date
    • Thread