here is a collection of gui fixes I applied to my tree to make it behave like MacOSX. Let me know what you think and apply them to trunk if applicable. Thanks to Tim McIntos for his improval of my validateEditing implementation.
Regards,
Andreas
NSWindow
This check on _firstResponder is really import otherwise makeFirstResponder returns NO if [window makeFirstResponder:nil] is called, which is wrong.
_firstResponder = aResponder;
if (_firstResponder) // <--- add this check
{
if (![_firstResponder becomeFirstResponder])
{
_firstResponder = self;
[_firstResponder becomeFirstResponder];
return NO;
}
}
...
}
NSTableView
Changing selection within the tableview should not be allowed if it is not firstResponder or if a cell being edited contains an invalid string.
- (void)mouseDown:(NSEvent *)theEvent
{
...
/* Stop editing if any */
if (_textObject != nil)
{
if (_editedCell != nil && [_editedCell isEntryAcceptable:[_textObject text]] == NO)
{
NSBeep();
return;
}
[self validateEditing];
[self abortEditing];
}
if ([[self window] firstResponder] != self)
{
NSBeep();
return;
}
// Determine row and column which were clicked
...
}
Check whether delegate responds to control:didFailToFormatString:errorDescription: before sending message and and accept empty string.
if (validatedOK)
{
[_cell setObjectValue:newObjectValue];
}
}
}
NSControl
The delegate of an NSControl should be able to access validated values with objectValue in -controlTextDidChange:(NSNotification *)obj (at least that's the behavior on MacOSX).