From e6497aafda5ecb92e1fe18f5e23999c2babec296 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Thu, 16 Sep 2010 01:00:12 +0000 Subject: - Consolidate structure and content row editing cancellation code into a single function in each class - Tweak NSTableView subclasses to catch presses of the Escape key and ask the class to abort row editing. This makes Esc key behaviour much more consistent, and allows cancelling/reverting edits made via the mouse (eg checkboxes, dropdowns, enums), or after the cell editing has finished but the row is still selected. - Remove debug - Update localisable strings --- Source/SPTableView.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'Source/SPTableView.m') diff --git a/Source/SPTableView.m b/Source/SPTableView.m index c3f76baf..aa0b5067 100644 --- a/Source/SPTableView.m +++ b/Source/SPTableView.m @@ -89,7 +89,7 @@ { // Check if ENTER or RETURN is hit and edit the column. - if([self numberOfSelectedRows] == 1 && ([theEvent keyCode] == 36 || [theEvent keyCode] == 76)) + if ([self numberOfSelectedRows] == 1 && ([theEvent keyCode] == 36 || [theEvent keyCode] == 76)) { if([[[[self delegate] class] description] isEqualToString:@"SPFieldMapperController"]) { @@ -126,6 +126,12 @@ } } + + // Check if ESCAPE is hit and use it to cancel row editing if supported + else if ([theEvent keyCode] == 53 && [[self delegate] respondsToSelector:@selector(cancelRowEditing)]) + { + if ([[self delegate] cancelRowEditing]) return; + } [super keyDown:theEvent]; -- cgit v1.2.3