• 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
A custom cell in a NSOutlineView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

A custom cell in a NSOutlineView


  • Subject: A custom cell in a NSOutlineView
  • From: Eric Gorr <email@hidden>
  • Date: Thu, 8 Jan 2009 14:44:18 -0500

Here is a picture of what I need to do:

http://ericgorr.net/cocoadev/customcell/customcell.png

Basically, I need a NSOutlineView which can contain a set of selectable images with titles that can be edited. It also needs to support keyboard navigation and when a section is opened (like Gradients), every item that section contains needs to be visible. I might be blanking on some other minor behaviors, but these are the fundamental ones.

My first thought was that I could just use a NSCollectionView, but this is not possible at the moment (rdar://6455493 & rdar://4857136).

My second idea is that I could just dynamically add and remove columns & rows, but the problem is that in order to display the group titles, the column they are displayed in needs to be wide...when I added multiple columns, the column of the group title was never wide enough - they would always get clipped. If I had continued down this line, I suspect I would have had trouble dynamically adding and removing columns as the user was resizing the NSPanel.

The third idea was to subclass NSTextFieldCell and do all of the drawing myself. Each group (Gradients, Hatches, Images, etc.) contains just a single row with a single subclass of a NSTextFieldCell. It is this implementation that is pictured above. As you can see it mostly works and I can dynamically alter the row height so each item fits and moves to different rows as needed. The problem I am having with this is that I cannot seem to get any help with tracking the mouse (see the thread http://tinyurl.com/9y8to9).

The final idea is to dump NSTextFieldCell, since it seems to be eating all mouseUp and mouse tracking information, and go with a completely custom cell. I understand this may be a lot of work, but I cannot see a way around it at the moment.

I am hoping that someone else might have some alternate ideas or a pointer to some sample code of a subclass of NSCell which was written to work with a NSTableView.

One alternative that had been suggested is to simulate a NSOutlineView with a NSCollectionView. However, it is unclear how well this would actually work. Would it support the editing of the names of the items? Would it support rows of different heights?


_______________________________________________

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: A custom cell in a NSOutlineView
      • From: Corbin Dunn <email@hidden>
  • Prev by Date: Re: Tiger vs Leopard Printing
  • Next by Date: Re: [NSOutlineView reloadData]
  • Previous by thread: Re: App Listener
  • Next by thread: Re: A custom cell in a NSOutlineView
  • Index(es):
    • Date
    • Thread