mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 19:00:47 +00:00
Fixed a couple of very technical bugs ... pressing TAB between cells while
editing would copy the string, and _editedCells wouldn't get released properly git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@12694 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b84227ca56
commit
f140aff6e3
1 changed files with 29 additions and 10 deletions
|
@ -4094,6 +4094,7 @@ byExtendingSelection: (BOOL)flag
|
||||||
NSText *t;
|
NSText *t;
|
||||||
NSTableColumn *tb;
|
NSTableColumn *tb;
|
||||||
NSRect drawingRect;
|
NSRect drawingRect;
|
||||||
|
unsigned length = 0;
|
||||||
|
|
||||||
// We refuse to edit cells if the delegate can not accept results
|
// We refuse to edit cells if the delegate can not accept results
|
||||||
// of editing.
|
// of editing.
|
||||||
|
@ -4119,12 +4120,16 @@ byExtendingSelection: (BOOL)flag
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now (_textObject == nil)
|
// Now (_textObject == nil)
|
||||||
|
|
||||||
t = [_window fieldEditor: YES forObject: self];
|
t = [_window fieldEditor: YES forObject: self];
|
||||||
|
|
||||||
if ([t superview] != nil)
|
if ([t superview] != nil)
|
||||||
if ([t resignFirstResponder] == NO)
|
{
|
||||||
return;
|
if ([t resignFirstResponder] == NO)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_editedRow = rowIndex;
|
_editedRow = rowIndex;
|
||||||
_editedColumn = columnIndex;
|
_editedColumn = columnIndex;
|
||||||
|
@ -4133,11 +4138,13 @@ byExtendingSelection: (BOOL)flag
|
||||||
tb = [_tableColumns objectAtIndex: columnIndex];
|
tb = [_tableColumns objectAtIndex: columnIndex];
|
||||||
// NB: need to be released when no longer used
|
// NB: need to be released when no longer used
|
||||||
_editedCell = [[tb dataCellForRow: rowIndex] copy];
|
_editedCell = [[tb dataCellForRow: rowIndex] copy];
|
||||||
|
|
||||||
[_editedCell setEditable: YES];
|
[_editedCell setEditable: YES];
|
||||||
[_editedCell setObjectValue: [_dataSource tableView: self
|
[_editedCell setObjectValue: [_dataSource tableView: self
|
||||||
objectValueForTableColumn: tb
|
objectValueForTableColumn: tb
|
||||||
row: rowIndex]];
|
row: rowIndex]];
|
||||||
|
|
||||||
|
|
||||||
// We really want the correct background color!
|
// We really want the correct background color!
|
||||||
if ([_editedCell respondsToSelector: @selector(setBackgroundColor:)])
|
if ([_editedCell respondsToSelector: @selector(setBackgroundColor:)])
|
||||||
{
|
{
|
||||||
|
@ -4155,12 +4162,24 @@ byExtendingSelection: (BOOL)flag
|
||||||
forTableColumn: tb row: rowIndex];
|
forTableColumn: tb row: rowIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Please note the important point - calling stringValue normally
|
||||||
|
causes the _editedCell to call the validateEditing method of its
|
||||||
|
control view ... which happens to be this NSTableView object :-)
|
||||||
|
but we don't want any spurious validateEditing to be performed
|
||||||
|
before the actual editing is started (otherwise you easily end up
|
||||||
|
with the table view picking up the string stored in the field
|
||||||
|
editor, which is likely to be the string resulting from the last
|
||||||
|
edit somewhere else ... getting into the bug that when you TAB
|
||||||
|
from one cell to another one, the string is copied!), so we must
|
||||||
|
call stringValue when _textObject is still nil. */
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
length = [[_editedCell stringValue] length];
|
||||||
|
}
|
||||||
|
|
||||||
_textObject = [_editedCell setUpFieldEditorAttributes: t];
|
_textObject = [_editedCell setUpFieldEditorAttributes: t];
|
||||||
|
|
||||||
// Now edit it
|
drawingRect = [self frameOfCellAtColumn: columnIndex row: rowIndex];
|
||||||
drawingRect = [self frameOfCellAtColumn: columnIndex
|
|
||||||
row: rowIndex];
|
|
||||||
|
|
||||||
if (flag)
|
if (flag)
|
||||||
{
|
{
|
||||||
[_editedCell selectWithFrame: drawingRect
|
[_editedCell selectWithFrame: drawingRect
|
||||||
|
@ -4168,7 +4187,7 @@ byExtendingSelection: (BOOL)flag
|
||||||
editor: _textObject
|
editor: _textObject
|
||||||
delegate: self
|
delegate: self
|
||||||
start: 0
|
start: 0
|
||||||
length: [[_editedCell stringValue] length]];
|
length: length];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -6108,8 +6127,8 @@ byExtendingSelection: (BOOL)flag
|
||||||
[self setNeedsDisplayInRect:
|
[self setNeedsDisplayInRect:
|
||||||
[self frameOfCellAtColumn: _editedColumn row: _editedRow]];
|
[self frameOfCellAtColumn: _editedColumn row: _editedRow]];
|
||||||
_textObject = nil;
|
_textObject = nil;
|
||||||
_editedCell = nil;
|
|
||||||
RELEASE (_editedCell);
|
RELEASE (_editedCell);
|
||||||
|
_editedCell = nil;
|
||||||
/* Save values */
|
/* Save values */
|
||||||
row = _editedRow;
|
row = _editedRow;
|
||||||
column = _editedColumn;
|
column = _editedColumn;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue