aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPOutlineView.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-11-09 18:19:12 +0000
committerstuconnolly <stuart02@gmail.com>2010-11-09 18:19:12 +0000
commit1af63b378e644ceef6e26918b0a1d693bcc232f8 (patch)
tree8bbf8a8e07266bbff51d35dca1d89a0c41c97016 /Source/SPOutlineView.m
parentd10ca821ae2f3ab62daf92f5e9bde58bf796e36c (diff)
downloadsequelpro-1af63b378e644ceef6e26918b0a1d693bcc232f8.tar.gz
sequelpro-1af63b378e644ceef6e26918b0a1d693bcc232f8.tar.bz2
sequelpro-1af63b378e644ceef6e26918b0a1d693bcc232f8.zip
First changes towards changing the initial connection view's favorites table list to an outline view in order to support grouping favorites. Future changes include creating a favorites data controller, including migrating favorites storage to their own plist in the app support directory as well as support for grouping favorites.
Diffstat (limited to 'Source/SPOutlineView.m')
-rw-r--r--Source/SPOutlineView.m38
1 files changed, 37 insertions, 1 deletions
diff --git a/Source/SPOutlineView.m b/Source/SPOutlineView.m
index 8eb55630..7ae50072 100644
--- a/Source/SPOutlineView.m
+++ b/Source/SPOutlineView.m
@@ -1,5 +1,5 @@
//
-// $Id: SPUserManager.m 856 2009-06-12 05:31:39Z mltownsend $
+// $Id$
//
// SPOutlineView.m
// sequel-pro
@@ -42,4 +42,40 @@
}
}
+/**
+ * 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
+{
+ // If more than one row is selected only return the default contextual menu
+ if ([self numberOfSelectedRows] > 1) return [self menu];
+
+ // Right-click at a row will select that row before ordering out the context menu
+ NSInteger row = [self rowAtPoint:[self convertPoint:[event locationInWindow] fromView:nil]];
+
+ if ((row >= 0) && (row < [self numberOfRows])) {
+ [self selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO];
+ [[self window] makeFirstResponder:self];
+ }
+
+ return [self menu];
+}
+
+/**
+ * To prevent right-clicking in a column's 'group' heading, ask the delegate if we support selecting it
+ * as this normally doesn't apply to left-clicks. If we do support selecting this row, simply pass on the event.
+ */
+- (void)rightMouseDown:(NSEvent *)event
+{
+ if ([[self delegate] respondsToSelector:@selector(outlineView:shouldSelectItem:)]) {
+ if ([[self delegate] outlineView:self shouldSelectItem:[self itemAtRow:[self rowAtPoint:[self convertPoint:[event locationInWindow] fromView:nil]]]]) {
+ [super rightMouseDown:event];
+ }
+ }
+ else {
+ [super rightMouseDown:event];
+ }
+}
+
@end