aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTableRelations.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2011-04-25 23:57:57 +0000
committerrowanbeentje <rowan@beent.je>2011-04-25 23:57:57 +0000
commit75e4e58eecf4ae1b8f25751b0bc7d457edcf57e8 (patch)
tree964b60108a9f41ba1adba08f82846911fd676ea8 /Source/SPTableRelations.m
parent25268f100c5f1b90ed5944b0123748d8a152b040 (diff)
downloadsequelpro-75e4e58eecf4ae1b8f25751b0bc7d457edcf57e8.tar.gz
sequelpro-75e4e58eecf4ae1b8f25751b0bc7d457edcf57e8.tar.bz2
sequelpro-75e4e58eecf4ae1b8f25751b0bc7d457edcf57e8.zip
- Add the ability to double-click in empty areas of the main tableviews to add new rows/records
Diffstat (limited to 'Source/SPTableRelations.m')
-rw-r--r--Source/SPTableRelations.m8
1 files changed, 8 insertions, 0 deletions
diff --git a/Source/SPTableRelations.m b/Source/SPTableRelations.m
index e62825c3..5160448f 100644
--- a/Source/SPTableRelations.m
+++ b/Source/SPTableRelations.m
@@ -27,6 +27,7 @@
#import "SPDatabaseDocument.h"
#import "SPTablesList.h"
#import "SPTableData.h"
+#import "SPTableView.h"
#import "SPAlertSheets.h"
@interface SPTableRelations (PrivateAPI)
@@ -61,6 +62,9 @@
// Set the table relation view's vertical gridlines if required
[relationsTableView setGridStyleMask:([[NSUserDefaults standardUserDefaults] boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone];
+ // Set the double-click action in blank areas of the table to create new rows
+ [relationsTableView setEmptyDoubleClickAction:@selector(addRelation:)];
+
// Set the strutcture and index view's font
BOOL useMonospacedFont = [[NSUserDefaults standardUserDefaults] boolForKey:SPUseMonospacedFonts];
@@ -163,6 +167,10 @@
*/
- (IBAction)addRelation:(id)sender
{
+
+ // Check whether table editing is permitted (necessary as some actions - eg table double-click - bypass validation)
+ if ([tableDocumentInstance isWorking] || [tablesListInstance tableType] != SPTableTypeTable) return;
+
// Set up the controls
[addRelationTableBox setTitle:[NSString stringWithFormat:NSLocalizedString(@"Table: %@", @"Add Relation sheet title, showing table name"), [tablesListInstance tableName]]];