NSTableView - Field Editor problem

  • I'm sure this is a corner I've somehow painted myself into, but I'm a little
    baffled by it, so I hope someone can get me out of it.

    I have an NSTableView using a data source, no bindings involved.

    I decided to make a column editable that contains rows of text data.  The
    problem is if I begin editing a row, then click another row, the table/field
    editor doesn't seem to react properly.  The new row gets selected, but the
    row that was being edited either goes blank or continues to draw like it is
    still being edited, even though it's not active for editing.

    There is no custom data cell in use.  No custom table view subclass.  This
    seems pretty basic, but something is amiss.

    Anyone with a notion of what's going wrong?

    Thanks,

    Eric
  • Are you calling [myTableView reloadData] after updating your model?

    --
    I.S.

    On Mar 15, 2007, at 3:22 PM, Eric Long wrote:

    > I'm sure this is a corner I've somehow painted myself into, but I'm
    > a little
    > baffled by it, so I hope someone can get me out of it.
    >
    > I have an NSTableView using a data source, no bindings involved.
    >
    > I decided to make a column editable that contains rows of text
    > data.  The
    > problem is if I begin editing a row, then click another row, the
    > table/field
    > editor doesn't seem to react properly.  The new row gets selected,
    > but the
    > row that was being edited either goes blank or continues to draw
    > like it is
    > still being edited, even though it's not active for editing.
    >
    > There is no custom data cell in use.  No custom table view
    > subclass.  This
    > seems pretty basic, but something is amiss.
    >
    > Anyone with a notion of what's going wrong?
    >
    >
    > Thanks,
    >
    >
    > Eric
  • > Are you calling [myTableView reloadData] after updating your model?

    I've tried a lot of things, including that.  However, the bug occurs without
    actually changing the text.  Just clicking to activate the editor, then
    selecting another row is sufficient.

    I tried calling reloadData when the selection changes, and that had no
    effect.

    Eric
  • Mystery solved...

    The array behind the table was a mutable copy from the prefs, but not a DEEP
    mutable copy.

    Strangely, I wasn't seeing any console messages about attempting to modify
    an immutable object, until after I noticed that in my awakeFromNib method I
    was programmatically setting up a column to use a checkbox for its data
    cell.  I commented out that code and set it up in IB instead.  Then after
    that change, suddenly the checkboxes would no longer toggle.  I  saw in the
    console I was getting a message telling me I was trying to modify an
    immutable object.

    I fixed the code to use a deep mutable copy of the array from prefs, and
    everything now works like it should.  No more bizarre drawing.

    Eric
previous month march 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