From 78331b709c5f43e6ecbdedd3af06ed0dcf398dc9 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Sat, 12 Jun 2010 17:56:09 +0000 Subject: - Alter the behaviour of the return key in structure view, making it consistent with the Content view and triggering a row save --- Source/SPTableStructure.m | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Source/SPTableStructure.m b/Source/SPTableStructure.m index bbab0785..6145774b 100644 --- a/Source/SPTableStructure.m +++ b/Source/SPTableStructure.m @@ -1595,9 +1595,9 @@ would result in a position change. row = [tableSourceView editedRow]; column = [tableSourceView editedColumn]; - if ( [textView methodForSelector:command] == [textView methodForSelector:@selector(insertNewline:)] || - [textView methodForSelector:command] == [textView methodForSelector:@selector(insertTab:)] ) //trap enter and tab - { + // Trap the tab key, selecting the next item in the line + if ( [textView methodForSelector:command] == [textView methodForSelector:@selector(insertTab:)] ) + { //save current line [[control window] makeFirstResponder:control]; if ( column == 9 ) { @@ -1618,10 +1618,20 @@ would result in a position change. } } return TRUE; + + // Trap the enter key, triggering a save + } + else if ( [textView methodForSelector:command] == [textView methodForSelector:@selector(insertNewline:)] ) + { + [[control window] makeFirstResponder:control]; + [self addRowToDB]; + return TRUE; - } else if ( [[control window] methodForSelector:command] == [[control window] methodForSelector:@selector(_cancelKey:)] || - [textView methodForSelector:command] == [textView methodForSelector:@selector(complete:)] ) { - //abort editing + // Trap escape, aborting the edit and reverting the row + } + else if ( [[control window] methodForSelector:command] == [[control window] methodForSelector:@selector(_cancelKey:)] || + [textView methodForSelector:command] == [textView methodForSelector:@selector(complete:)] ) + { [control abortEditing]; if ( isEditingRow && !isEditingNewRow ) { isEditingRow = NO; -- cgit v1.2.3