aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2013-02-21 00:50:15 +0000
committerrowanbeentje <rowan@beent.je>2013-02-21 00:50:15 +0000
commit77b2f3d777bc743b7b96a9f2267d1a89d704510d (patch)
tree36a5a2b9369b696a280e9ca6ad1e195e8f74de44 /Source
parent9aaa544772539410f28df132be78e0f44da1db10 (diff)
downloadsequelpro-77b2f3d777bc743b7b96a9f2267d1a89d704510d.tar.gz
sequelpro-77b2f3d777bc743b7b96a9f2267d1a89d704510d.tar.bz2
sequelpro-77b2f3d777bc743b7b96a9f2267d1a89d704510d.zip
- When favorites in the connection view gave no password, no longer set the focus to the password field as soon as they're selected; instead, make the password field the next responder for tab keys. This addresses Issue #1555.
Diffstat (limited to 'Source')
-rw-r--r--Source/SPConnectionController.m29
-rw-r--r--Source/SPConnectionControllerDelegate.m8
-rw-r--r--Source/SPDatabaseDocument.m8
-rw-r--r--Source/SPFavoritesOutlineView.h2
-rw-r--r--Source/SPFavoritesOutlineView.m21
5 files changed, 65 insertions, 3 deletions
diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m
index 9e0d50cd..898d8154 100644
--- a/Source/SPConnectionController.m
+++ b/Source/SPConnectionController.m
@@ -651,8 +651,33 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
[prefs setInteger:[[fav objectForKey:SPFavoriteIDKey] integerValue] forKey:SPLastFavoriteID];
- // Set first responder to password field if it is empty
- [self performSelector:@selector(_updateFavoriteFirstResponder) withObject:nil afterDelay:0.0];
+ // Set the next KeyView to password field if the password is empty
+ switch ([self type])
+ {
+ case SPTCPIPConnection:
+ if (![[standardPasswordField stringValue] length]) {
+ [favoritesOutlineView setNextKeyView:standardPasswordField];
+ } else {
+ [favoritesOutlineView setNextKeyView:standardNameField];
+ }
+ break;
+ case SPSocketConnection:
+ if (![[socketPasswordField stringValue] length]) {
+ [favoritesOutlineView setNextKeyView:socketPasswordField];
+ } else {
+ [favoritesOutlineView setNextKeyView:socketNameField];
+ }
+ break;
+ case SPSSHTunnelConnection:
+ if (![[sshPasswordField stringValue] length]) {
+ [favoritesOutlineView setNextKeyView:sshPasswordField];
+ } else if (![[sshSSHPasswordField stringValue] length]) {
+ [favoritesOutlineView setNextKeyView:sshSSHPasswordField];
+ } else {
+ [favoritesOutlineView setNextKeyView:sshNameField];
+ }
+ break;
+ }
#endif
}
diff --git a/Source/SPConnectionControllerDelegate.m b/Source/SPConnectionControllerDelegate.m
index ec1c65f1..28dd8282 100644
--- a/Source/SPConnectionControllerDelegate.m
+++ b/Source/SPConnectionControllerDelegate.m
@@ -40,6 +40,7 @@
#import "SPFavoriteNode.h"
#import "SPGroupNode.h"
#import "SPTreeNode.h"
+#import "SPFavoritesOutlineView.h"
#endif
#ifndef SP_CODA
@@ -260,6 +261,13 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf";
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
+ NSEvent *event = [NSApp currentEvent];
+ BOOL shiftTabbedIn = ([event type] == NSKeyDown && [[event characters] length] && [[event characters] characterAtIndex:0] == NSBackTabCharacter);
+
+ if (shiftTabbedIn && [(SPFavoritesOutlineView *)outlineView justGainedFocus]) {
+ return NO;
+ }
+
return (item != quickConnectItem);
}
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index 577306ae..eb61c6fc 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -4195,6 +4195,13 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
// Add the progress window to this window
[self centerTaskWindow];
[parentWindow addChildWindow:taskProgressWindow ordered:NSWindowAbove];
+
+#ifndef SP_CODA
+ // If not connected, update the favorite selection
+ if (!_isConnected) {
+ [connectionController updateFavoriteSelection:self];
+ }
+#endif
}
/**
@@ -4239,7 +4246,6 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
// If the window is being set for the first time - connection controller is visible - update focus
if (!parentWindow && !mySQLConnection) {
[aWindow makeFirstResponder:(NSResponder *)[connectionController favoritesOutlineView]];
- [connectionController updateFavoriteSelection:self];
}
#endif
diff --git a/Source/SPFavoritesOutlineView.h b/Source/SPFavoritesOutlineView.h
index c2d8a8eb..d2fa0846 100644
--- a/Source/SPFavoritesOutlineView.h
+++ b/Source/SPFavoritesOutlineView.h
@@ -35,4 +35,6 @@
SInt32 systemVersion;
}
+@property (assign) BOOL justGainedFocus;
+
@end
diff --git a/Source/SPFavoritesOutlineView.m b/Source/SPFavoritesOutlineView.m
index f4fc3a7a..6972309b 100644
--- a/Source/SPFavoritesOutlineView.m
+++ b/Source/SPFavoritesOutlineView.m
@@ -37,6 +37,8 @@ static NSUInteger SPFavoritesOutlineViewUnindent = 6;
@implementation SPFavoritesOutlineView
+@synthesize justGainedFocus;
+
- (void) awakeFromNib
{
systemVersion = 0;
@@ -45,9 +47,19 @@ static NSUInteger SPFavoritesOutlineViewUnindent = 6;
- (BOOL)acceptsFirstResponder
{
+ if ([[self window] firstResponder] != self) {
+ [self setJustGainedFocus:YES];
+ }
+
return YES;
}
+- (BOOL)resignFirstResponder
+{
+ [self setJustGainedFocus:NO];
+ return [super resignFirstResponder];;
+}
+
/**
* Right-click at row will select that row before ordering out the contextual menu
* if not more than one row is selected.
@@ -76,6 +88,15 @@ static NSUInteger SPFavoritesOutlineViewUnindent = 6;
[[self delegate] performSelector:[self doubleAction]];
return;
+
+ // If the Tab key is used, change focus rather than entering edit mode.
+ } else if ([[event characters] length] && [[event characters] characterAtIndex:0] == NSTabCharacter) {
+ if (([event modifierFlags] & NSShiftKeyMask) != NSShiftKeyMask) {
+ [[self window] selectKeyViewFollowingView:self];
+ } else {
+ [[self window] selectKeyViewPrecedingView:self];
+ }
+ return;
}
[super keyDown:event];