Resizable field editor in NSTableView

  • Hello all!

    I was wondering if anyone has any tips on getting a field editor to
    resize during editing in an NSTableView?  I've got a table view with
    variable row heights working correctly using tableView:heightOfRow: ,
    but I would really like to be able to resize the row (or at least the
    field editor until editing is complete) while the user is entering
    text.  I've been looking through the archives and searching the web,
    but have come up dry.  Any pointers?

    Thanks,
    Dave Rosborough
  • You need to add an auxiliary view to the field editor by replacing it
    with a custom subclass.
    What I did was create a custom scrollview, add a text view in it, use
    the scrollview to resize the enclosing
    textview, and use forward invocation to call all the other methods
    sent to the field editor past the enclosing
    view to its real destination.

    In other words, the returned field editor (from the window delegate)
    checks if
    the calling object is an NSTextfieldCell (specifically my custom
    subclass) and returns my special view that contains
    the textview/scrollview combo and fakes itself as just a texteditor
    by forward invocation. Otherwise you return the normal
    windows field editor...

    Its possible thanks to Objective-C runtime.

    On $BJ?@.(B 17/09/01, at 8:17, Dave Rosborough wrote:

    > Hello all!
    >
    > I was wondering if anyone has any tips on getting a field editor to
    > resize during editing in an NSTableView?  I've got a table view
    > with variable row heights working correctly using
    > tableView:heightOfRow: , but I would really like to be able to
    > resize the row (or at least the field editor until editing is
    > complete) while the user is entering text.  I've been looking
    > through the archives and searching the web, but have come up dry.
    > Any pointers?
    >
    > Thanks,
    > Dave Rosborough
    >
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Cocoa-dev mailing list      (<Cocoa-dev...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/cocoa-dev/<son_gohan...>
    >
    > This email sent to <son_gohan...>
    >
  • Yes, this is correct.
    An active textfield cell is actually within a special private
    scrollview _NSKeyboardFocusClipView,
    if you traverse the view hierarchy you'll run into it.

    In your example, what is "self"? Is it an NSTextView or the cell or ...?

    If its the cell or even NSText, try [[self superview]
    setFrameSize:size];
    You'll wanna traverse the view hierarchy and when you run into
    _NSKeyboardFocusClipView
    thats the one to change IIRC. Also, _NSKeyboardFocusClipView wont
    resize unless its
    first responder IIRC.

    I had the same problem, and I'm not sure exactly how your doing it...

    Since your in a table view, why don't you just bypass the cell/
    scrollview resizing
    and change the height of the row appropriately calling
    setNeedsDisplay:YES to the
    table view afterwards?

    Hope it helps...

    On $BJ?@.(B 17/09/01, at 23:59, Dave Rosborough wrote:

    > Thanks for the suggestion!
    >
    > I have most of it working, except I'm struggling to get the
    > scrollview itself to resize correctly as the user enter text.  Just
    > doing:
    >
    > [self setFrameSize:[[myTextView textStorage] size]];
    >
    > in the scrollview when an NSTextDidChangeNotification is posted
    > doesn't work, and I couldn't find any other obvious way to do that.
    >
    > Any help would be greatly appreciated!
    >
    > Thanks,
    > Dave Rosborough
    >
    > On 31-Aug-05, at 5:01 PM, Andre wrote:
    >
    >
    >
    >
    >> You need to add an auxiliary view to the field editor by replacing
    >> it with a custom subclass.
    >> What I did was create a custom scrollview, add a text view in it,
    >> use the scrollview to resize the enclosing
    >> textview, and use forward invocation to call all the other methods
    >> sent to the field editor past the enclosing
    >> view to its real destination.
    >> Its possible thanks to Objective-C runtime.
    >>
    >> On $BJ?@.(B 17/09/01, at 8:17, Dave Rosborough wrote:
    >>
    >>
    >>
    >>
    >>> I was wondering if anyone has any tips on getting a field editor
    >>> to resize during editing in an NSTableView?  I've got a table
    >>> view with variable row heights working correctly using
    >>> tableView:heightOfRow: , but I would really like to be able to
    >>> resize the row (or at least the field editor until editing is
    >>> complete) while the user is entering text.  I've been looking
    >>> through the archives and searching the web, but have come up
    >>> dry.  Any pointers?
    >>>
    >>>
    >>>
    >
    >
    >
    >
previous month september 2005 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