Custom editable cell on NSOutlineView

  • I have an NSOutlineView that needs each cell to have a small icon and
    be editable.

    So far, I've used NSBrowserCell, which does the icon perfectly but
    refuses to work with editing. I also tried the ImageAndTextCell
    sample code from ADC ( http://developer.apple.com/samplecode/
    ImageBackground/listing4.html ), which has code in it for editing,
    but it doesn't work either (again, icons and text display properly,
    but editing doesn't function). Editing works fine if I revert to the
    default data cell. Any ideas on how I can get editing and the icon
    working?

    Here's how I'm setting the data cell (for NSBrowserCell, on a
    NSOutlineView with one column):
    NSBrowserCell *browserCell = [[[NSBrowserCell alloc] init]
    autorelease];
    [browserCell setLeaf:YES];
    [[[_hierarchyView tableColumns] objectAtIndex:0]
    setDataCell:browserCell];
  • Dorian Johnson wrote:
    > I have an NSOutlineView that needs each cell to have a small icon and be
    > editable.
    >
    > So far, I've used NSBrowserCell, which does the icon perfectly but
    > refuses to work with editing. I also tried the ImageAndTextCell sample
    > code from ADC (
    > http://developer.apple.com/samplecode/ImageBackground/listing4.html ),
    > which has code in it for editing, but it doesn't work either (again,
    > icons and text display properly, but editing doesn't function). Editing
    > works fine if I revert to the default data cell. Any ideas on how I can
    > get editing and the icon working?
    >
    > Here's how I'm setting the data cell (for NSBrowserCell, on a
    > NSOutlineView with one column):
    > NSBrowserCell *browserCell = [[[NSBrowserCell alloc] init]
    > autorelease];
    > [browserCell setLeaf:YES];
    > [[[_hierarchyView tableColumns] objectAtIndex:0]
    > setDataCell:browserCell];

    You initialization lacks:
          [browserCell setEditable:YES];

    This should be enough.

    Hope this helps,
    Florent
  • Thanks, that did the trick! I didn't even think of that.

    On Nov 4, 2007, at 4:06 PM, Florent Pillet wrote:

    > [browserCell setEditable:YES];
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today