I have an NSTableView that has one column of editable fields. Cell editing works fine, and my delegate routines get the update and can act on them as needed. The problem is that there is other code that updates values in the table based on timer or asynchronous (socket) input. When an updates event happens while editing is in progress, the update overwrites the user input.
I'm trying to use the delegate methods to block updates with an instance variable lock:
- (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)fieldEditor;
{
tableEditInProgress = YES;
return YES;
}
- (BOOL)control:(NSControl *)control textShouldEndEditing:(NSText *)fieldEditor
{
tableEditInProgress = NO;
return YES;
}
- (void)controlTextDidBeginEditing:(NSNotification *)aNotification
{
tableEditInProgress = YES;
}
- (void)controlTextDidEndEditing:(NSNotification *)aNotification
{
tableEditInProgress = NO;
}
This only seems to work if the user actually types new text in the field before the update happens. I want updates to be blocked as soon as the user gets an edit cursor in the field (double click field contents).
I'm probably just using the wrong delegate methods.
TIA
joe