aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTableView.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2011-04-22 17:44:57 +0000
committerstuconnolly <stuart02@gmail.com>2011-04-22 17:44:57 +0000
commit4611475c5b255eed9202474dd3bdee147e932946 (patch)
tree39bdc50e046f802265950c6e2607ca9ebda453be /Source/SPTableView.m
parent3ed8b33deeadcc98185911f41bc6bcb4e53b4719 (diff)
downloadsequelpro-4611475c5b255eed9202474dd3bdee147e932946.tar.gz
sequelpro-4611475c5b255eed9202474dd3bdee147e932946.tar.bz2
sequelpro-4611475c5b255eed9202474dd3bdee147e932946.zip
Bring outline view branch up to date with trunk (r3234:3277).
Diffstat (limited to 'Source/SPTableView.m')
-rw-r--r--Source/SPTableView.m45
1 files changed, 36 insertions, 9 deletions
diff --git a/Source/SPTableView.m b/Source/SPTableView.m
index 226bfe6c..d678fef3 100644
--- a/Source/SPTableView.m
+++ b/Source/SPTableView.m
@@ -36,12 +36,15 @@
@implementation SPTableView
+@synthesize tabEditingDisabled;
+
/**
* Right-click at row will select that row before ordering out the contextual menu
* if not more than one row is selected.
*/
- (NSMenu *)menuForEvent:(NSEvent *)event
{
+#ifndef SP_REFACTOR /* menuForEvent: */
// Try to retrieve a reference to the table document (assuming this is frontmost tab)
SPDatabaseDocument *parentTableDocument = nil;
@@ -65,24 +68,24 @@
// Check for SPTablesList if right-click on header, then suppress context menu
if ([[[[self delegate] class] description] isEqualToString:@"SPTablesList"]) {
- if ([NSArrayObjectAtIndex([[self delegate] valueForKeyPath:@"tableTypes"], row) integerValue] == -1)
+ if ([NSArrayObjectAtIndex([(NSObject*)[self delegate] valueForKeyPath:@"tableTypes"], row) integerValue] == -1)
return nil;
}
if ([[[[self delegate] class] description] isEqualToString:@"SPQueryFavoriteManager"]) {
- if ([NSArrayObjectAtIndex([[self delegate] valueForKeyPath:@"favorites"], row) objectForKey:@"headerOfFileURL"])
+ if ([NSArrayObjectAtIndex([(NSObject*)[self delegate] valueForKeyPath:SPFavorites], row) objectForKey:@"headerOfFileURL"])
return nil;
}
if ([[[[self delegate] class] description] isEqualToString:@"SPContentFilterManager"]) {
- if ([NSArrayObjectAtIndex([[self delegate] valueForKeyPath:@"contentFilters"], row) objectForKey:@"headerOfFileURL"])
+ if ([NSArrayObjectAtIndex([(NSObject*)[self delegate] valueForKeyPath:@"contentFilters"], row) objectForKey:@"headerOfFileURL"])
return nil;
}
[self selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO];
[[self window] makeFirstResponder:self];
}
-
+#endif
return [self menu];
}
@@ -91,23 +94,36 @@
return YES;
}
+/**
+ * On becomeFirstResponder, if editing is disabled, override the super and just
+ * display instead; this prevents the selected cell from automatically editing
+ * if the table is backtabbed to.
+ */
+- (BOOL)becomeFirstResponder {
+ if (tabEditingDisabled) {
+ [self display];
+ return YES;
+ }
+ return [super becomeFirstResponder];
+}
+
- (void)keyDown:(NSEvent *)theEvent
{
// Check if ENTER or RETURN is hit and edit the column.
if ([self numberOfSelectedRows] == 1 && ([theEvent keyCode] == 36 || [theEvent keyCode] == 76)) {
if ([[[[self delegate] class] description] isEqualToString:@"SPFieldMapperController"]) {
- if ([[self delegate] isGlobalValueSheetOpen]) {
- [[self delegate] closeGlobalValuesSheet:nil];
+ if ([(SPFieldMapperController*)[self delegate] isGlobalValueSheetOpen]) {
+ [(SPFieldMapperController*)[self delegate] closeGlobalValuesSheet:nil];
return;
}
// ENTER or RETURN closes the SPFieldMapperController sheet
// by sending an object with the tag 1 if no table cell is edited
- if ([[self delegate] canBeClosed]) {
+ if ([(SPFieldMapperController*)[self delegate] canBeClosed]) {
NSButton *b = [[[NSButton alloc] init] autorelease];
[b setTag:1];
- [[self delegate] closeSheet:b];
+ [(SPFieldMapperController*)[self delegate] closeSheet:b];
return;
}
@@ -131,9 +147,20 @@
return;
}
}
+
// 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;
+ if ([[self delegate] performSelector:@selector(cancelRowEditing)]) return;
+ }
+
+ // If the Tab key is used, but tab editing is disabled, change focus rather than entering edit mode.
+ else if (tabEditingDisabled && [[theEvent characters] length] && [[theEvent characters] characterAtIndex:0] == NSTabCharacter) {
+ if (([theEvent modifierFlags] & NSShiftKeyMask) != NSShiftKeyMask) {
+ [[self window] selectKeyViewFollowingView:self];
+ } else {
+ [[self window] selectKeyViewPrecedingView:self];
+ }
+ return;
}
[super keyDown:theEvent];