diff --git a/Source/NSMatrix.m b/Source/NSMatrix.m index 0a43b564e..6be6562f8 100644 --- a/Source/NSMatrix.m +++ b/Source/NSMatrix.m @@ -1262,6 +1262,7 @@ static SEL getSel; { NSText *t = [_window fieldEditor: YES forObject: self]; + int length; if ([t superview] != nil) if ([t resignFirstResponder] == NO) @@ -1270,6 +1271,8 @@ static SEL getSel; _selectedCell = _cells[row][column]; _selectedRow = row; _selectedColumn = column; + /* See comment in NSTextField */ + length = [[_selectedCell stringValue] length]; _textObject = [_selectedCell setUpFieldEditorAttributes: t]; [_selectedCell selectWithFrame: [self cellFrameAtRow: _selectedRow column: _selectedColumn] @@ -1277,7 +1280,7 @@ static SEL getSel; editor: _textObject delegate: self start: 0 - length: [[_selectedCell stringValue] length]]; + length: length]; return _selectedCell; } } diff --git a/Source/NSTextField.m b/Source/NSTextField.m index d95e0e7c8..f0ea73552 100644 --- a/Source/NSTextField.m +++ b/Source/NSTextField.m @@ -127,19 +127,23 @@ static NSNotificationCenter *nc; { NSText *t = [_window fieldEditor: YES forObject: self]; + int length; if ([t superview] != nil) if ([t resignFirstResponder] == NO) return; // [NSCursor hide]; + /* [self stringValue] generates a call to validateEditing + so we need to call it before setting up the _text_object */ + length = [[self stringValue] length]; _text_object = [_cell setUpFieldEditorAttributes: t]; [_cell selectWithFrame: _bounds - inView: self - editor: _text_object - delegate: self - start: 0 - length: [[self stringValue] length]]; + inView: self + editor: _text_object + delegate: self + start: 0 + length: length]; } } }