Resizable Text Cell in NSTableView

  • Howdy,

    I'm trying to get an editing text cell to resize when changing the
    value (rename a playlist in iTunes, any file in Finder's list mode, a
    file in Finder's sidebar, or modify any field in Address Book). I
    tested the NSText methods for resizing with the code below, but that
    didn't work. The text field remains the same size. Any ideas?

    - (NSText *)setUpFieldEditorAttributes:(NSText *)textObj;
    {
    textObj = [super setUpFieldEditorAttributes:textObj];
    [textObj setHorizontallyResizable:YES];
    [textObj setMinSize:NSMakeSize(0.0, [textObj minSize].height)];
    [textObj setMaxSize:NSMakeSize(200.0, [textObj maxSize].height)];
    return textObj;
    }

    --
    Seth Willits
  • The general approach is to create a custom NSTextView subclass for the
    field editor, and to return it from an NSWindow subclass via - (NSText
    *)fieldEditor:(BOOL)createFlag forObject:(id)anObject. However, it
    isn't easy to get all the details right.

    Please do log bugs requesting this ability in NSTableView itself.

    -corbin

    On Feb 25, 2008, at 12:21 PM, Seth Willits wrote:

    > Howdy,
    >
    >
    > I'm trying to get an editing text cell to resize when changing the
    > value (rename a playlist in iTunes, any file in Finder's list mode,
    > a file in Finder's sidebar, or modify any field in Address Book). I
    > tested the NSText methods for resizing with the code below, but that
    > didn't work. The text field remains the same size. Any ideas?
    >
    >
    > - (NSText *)setUpFieldEditorAttributes:(NSText *)textObj;
    > {
    > textObj = [super setUpFieldEditorAttributes:textObj];
    > [textObj setHorizontallyResizable:YES];
    > [textObj setMinSize:NSMakeSize(0.0, [textObj minSize].height)];
    > [textObj setMaxSize:NSMakeSize(200.0, [textObj maxSize].height)];
    > return textObj;
    > }