aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPDatabaseDocument.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2012-08-30 00:28:56 +0000
committerrowanbeentje <rowan@beent.je>2012-08-30 00:28:56 +0000
commit28734c995b3f97d8eb50610cfd6d7ad62697d2cb (patch)
tree243d4d6e188c3a450d84396395dd101cc3569ca9 /Source/SPDatabaseDocument.m
parent83e1b0430ef46225aa1c1108e960c3758d5086e3 (diff)
downloadsequelpro-28734c995b3f97d8eb50610cfd6d7ad62697d2cb.tar.gz
sequelpro-28734c995b3f97d8eb50610cfd6d7ad62697d2cb.tar.bz2
sequelpro-28734c995b3f97d8eb50610cfd6d7ad62697d2cb.zip
- Fix the SPSplitView helper to correctly restore focus to focussed responders in an expanding view at the end of the animation
- On initial launch, and when changing database, ensure that the window focus is set to the table list or the table list filter or the table list as appropriate. This addresses Issue #1437. - Clean up some logic
Diffstat (limited to 'Source/SPDatabaseDocument.m')
-rw-r--r--Source/SPDatabaseDocument.m53
1 files changed, 21 insertions, 32 deletions
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index c296fba6..9bcb9733 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -535,10 +535,6 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
queryEditorInitString = nil;
}
- // Set focus to table list filter field if visible
- // otherwise set focus to Table List view
- [self focusOnTableListFilter:self];
-
if (spfSession != nil) {
// Restore vertical split view divider for tables' list and right view (Structure, Content, etc.)
@@ -578,6 +574,10 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
}
if ([self database]) [self detectDatabaseEncoding];
+
+ // Set focus to table list filter field if visible
+ // otherwise set focus to Table List view
+ [[tablesListInstance onMainThread] makeTableListFilterHaveFocus];
#endif
#ifdef SP_REFACTOR /* glue */
if ( delegate && [delegate respondsToSelector:@selector(databaseDocumentDidConnect:)] )
@@ -2298,14 +2298,6 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
}
/**
- * Makes the tables list filter field the first responder.
- */
-- (IBAction)focusOnTableListFilter:(id)sender
-{
- [[tablesListInstance onMainThread] performSelector:@selector(makeTableListFilterHaveFocus) withObject:nil afterDelay:0.25];
-}
-
-/**
* Exports the selected tables in the chosen file format.
*/
- (IBAction)exportSelectedTablesAs:(id)sender
@@ -6045,13 +6037,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
selectedDatabase = [[NSString alloc] initWithString:targetDatabaseName];
#endif
-#ifndef SP_REFACTOR /* clear SPTablesList selection */
- // If the item has changed, clear the item selection for cleaner loading
- if (![targetItemName isEqualToString:[self table]]) {
- [[tablesListInstance onMainThread] setTableListSelectability:YES];
- [[[tablesListInstance valueForKey:@"tablesListView"] onMainThread] deselectAll:self];
- [[tablesListInstance onMainThread] setTableListSelectability:NO];
- }
+#ifndef SP_REFACTOR /* update database encoding */
// Update the stored database encoding, used for views, "default" table encodings, and to allow
// or disallow use of the "View using encoding" menu
@@ -6071,25 +6057,28 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
[spHistoryControllerInstance setModifyingState:NO];
[spHistoryControllerInstance updateHistoryEntries];
}
-
- // Set focus to table list filter field if visible
- // otherwise set focus to Table List view
- [self focusOnTableListFilter:self];
#endif
}
#ifndef SP_REFACTOR /* update selected table in SPTablesList */
+
+ BOOL focusOnFilter = YES;
+ if (targetItemName) focusOnFilter = NO;
+
// If a the table has changed, update the selection
- if (![targetItemName isEqualToString:[self table]]) {
- if (targetItemName) {
- [tablesListInstance selectItemWithName:targetItemName];
- }
- else {
- [[tablesListInstance onMainThread] setTableListSelectability:YES];
- [[[tablesListInstance valueForKey:@"tablesListView"] onMainThread] deselectAll:self];
- [[tablesListInstance onMainThread] setTableListSelectability:NO];
- }
+ if (![targetItemName isEqualToString:[self table]] && targetItemName) {
+ focusOnFilter = ![tablesListInstance selectItemWithName:targetItemName];
+ }
+
+ // Ensure the window focus is on the table list or the filter as appropriate
+ [[tablesListInstance onMainThread] setTableListSelectability:YES];
+ if (focusOnFilter) {
+ [[tablesListInstance onMainThread] makeTableListFilterHaveFocus];
+ } else {
+ [[tablesListInstance onMainThread] makeTableListHaveFocus];
}
+ [[tablesListInstance onMainThread] setTableListSelectability:NO];
+
#endif
[self endTask];
#ifndef SP_REFACTOR /* triggered commands */