reading NSTableView cell edits before user tabs or enters

  • I am using an NSTableview and would like to better trap table cell edits as they happen.

    1) I would like to be able to monitor changes to manage updateChangeCount during table cell editing.

    2) If the user presses command-S to save, I would like to report the current cell edits/contents to the data source for saving.

    I can trap THAT A CELL HAS CHANGED with controlTextDidChange. The problem is that I don't know the mechanism for reading active cell edits before the user tabs or enters (i.e. the content of the changes) and they are reported via:

    - (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex

    There must be some way to provide a row and column to the NSTableView and then to see NSCell edits before they are completed/implemented, right?

    Thanks for your help.

    Randy

          ____________________________________________________________________________________
    Get easy, one-click access to your favorites.
    Make Yahoo! your homepage.
    http://www.yahoo.com/r/hs
  • Hi,

    I haven't tried it out, but it seems like some of the other delegate
    methods should do the trick:

    controlTextDidChange:
    control:textShouldEndEditing:

    You can also grab the value of the current (text) cell being edited
    from the field editor:

    <http://developer.apple.com/documentation/Cocoa/Conceptual/TextArchitecture/
    Concepts/TextFieldsAndViews.html
    >
    <http://developer.apple.com/documentation/Cocoa/Conceptual/TextEditing/Tasks
    /FieldEditor.html
    >

    Cheers,

    j o a r

    On Nov 16, 2007, at 7:43 AM, Randy Hulett wrote:

    > I am using an NSTableview and would like to better trap table cell
    > edits as they happen.
    >
    > 1) I would like to be able to monitor changes to manage
    > updateChangeCount during table cell editing.
    >
    > 2) If the user presses command-S to save, I would like to report the
    > current cell edits/contents to the data source for saving.
    >
    >
    >
    >
    > I can trap THAT A CELL HAS CHANGED with controlTextDidChange. The
    > problem is that I don't know the mechanism for reading active cell
    > edits before the user tabs or enters (i.e. the content of the
    > changes) and they are reported via:
    >
    > - (void)tableView:(NSTableView *)aTableView setObjectValue:
    > (id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:
    > (int)rowIndex
    >
    >
    >
    >
    > There must be some way to provide a row and column to the
    > NSTableView and then to see NSCell edits before they are completed/
    > implemented, right?
    >
    >
    >
    >
    > Thanks for your help.
    >
    > Randy
  • > I can trap THAT A CELL HAS CHANGED with controlTextDidChange. The
    > problem is that I don't know the mechanism for reading active cell
    > edits before the user tabs or enters (i.e. the content of the changes)

    That's because, until tab or enter or whatever is pressed, the value
    is not actually in your cell. It's in the field editor that's editing
    your cell. I think you should be able to ask the field editor for its
    value... you can get ahold of it using:

    [myWindow fieldEditor:NO forObject:nil]

    BUT if you just want to get this value so you can commit it before
    saving, an easier solution would be to take focus away from the edited
    cell before saving. This will automatically cause the filed editor to
    commit its value to the cell and the proper data will get saved.

    [myWindow makeFirstResponder:nil]

    should do the trick. It will send a -resignFirstResponder to the
    current first responder (in this case, the field editor).

    Cheers,
    -Joshua Emmons
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