Source Lists

  • Hi list,
      Leopard has the ability to specify that an outline view is a source
    list, but what I haven't figured out, is how to replicate the headings
    (e.g. "DEVICES" in Finder).  I could of course return an
    NSAttributedString to the outline view, but I get the feeling that's
    the wrong way to do it (TM). I then have to guess what styles the text
    should have, and as soon as apple update, it will look odd.

    Can anyone recommend to me what the right way to do this is?

    Thanks

    Tom Davie
  • Leopard discussion isn't allowed on this list for another three and a half hours. But without going into any specific knowledge of Leopard, if I were faced with a problem like this, I'd look at the included example code to see if there were any that did something similar to this.

    Cheers,
    Chuck

    ----- Original Message ----
    From: Thomas Davie <tom.davie...>
    To: <cocoa-dev...>
    Sent: Friday, October 26, 2007 2:31:19 PM
    Subject: Source Lists

    Hi list,
      Leopard has the ability to specify that an outline view is a source

    list, but what I haven't figured out, is how to replicate the headings

    (e.g. "DEVICES" in Finder).  I could of course return an
    NSAttributedString to the outline view, but I get the feeling that's
    the wrong way to do it (TM). I then have to guess what styles the text

    should have, and as soon as apple update, it will look odd.

    Can anyone recommend to me what the right way to do this is?

    Thanks

    Tom Davie

    __________________________________________________
    Do You Yahoo!?
    Tired of spam?  Yahoo! Mail has the best spam protection around
    http://mail.yahoo.com
  • It isn't quite as simple as you might think. In 17 minutes I'll be
    able to tell what makes it more complex than it should be.

    But I'll be putting up some code on my blog (toxicsoftware.com) that
    should do everything you need to do.

    Jon.

    On Oct 26, 2007, at 17:31, Thomas Davie wrote:

    > Hi list,
    > Leopard has the ability to specify that an outline view is a source
    > list, but what I haven't figured out, is how to replicate the
    > headings (e.g. "DEVICES" in Finder).  I could of course return an
    > NSAttributedString to the outline view, but I get the feeling that's
    > the wrong way to do it (TM). I then have to guess what styles the
    > text should have, and as soon as apple update, it will look odd.
    >
    > Can anyone recommend to me what the right way to do this is?
    >
    > Thanks
    >
    > Tom Davie
  • On Oct 26, 2007, at 2:31 PM, Thomas Davie wrote:

    > Hi list,
    > Leopard has the ability to specify that an outline view is a source
    > list, but what I haven't figured out, is how to replicate the
    > headings (e.g. "DEVICES" in Finder).  I could of course return an
    > NSAttributedString to the outline view, but I get the feeling that's
    > the wrong way to do it (TM). I then have to guess what styles the
    > text should have, and as soon as apple update, it will look odd.
    >
    > Can anyone recommend to me what the right way to do this is?

    I guess they've officially given the go-ahead, so here's a Leopard-
    only solution to make things look right. Getting the selection and
    drag behavior right is left as an exercise for the reader.

    Implement the following delegate methods for NSOutlineView with the
    source list style turned on. Assuming, of course, that you're using a
    subclass of NSTextFieldCell for display. Return a regular NSString as
    the object value for the table column.

    - (BOOL)outlineView:(NSOutlineView *)sender isGroupItem:(id)item {
    if (ITEM IS HEADING)
      return YES;
    else
      return NO;
    }

    - (void)outlineView:(NSOutlineView *)sender willDisplayCell:(id)cell
    forTableColumn:(NSTableColumn *)tableColumn item:(id)item {
    if (ITEM IS HEADING) {
               NSMutableAttributedString *newTitle = [[cell
    attributedStringValue] mutableCopy];
              [newTitle replaceCharactersInRange:NSMakeRange(0,[newTitle
    length]) withString:[[newTitle string] uppercaseString]];
              [cell setAttributedStringValue:newTitle];
              [newTitle release];
    }
    }

    -> jp
previous month october 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 31        
Go to today