From 5914260a1ca2db3da190fde077145756ba169bf4 Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Mon, 9 May 2011 20:08:53 +0000 Subject: Add the ability to double click a tab to duplicate the connection in a new tab (equivalent to the 'Open Database in New Tab' menu item). Implements issue #1040. --- Frameworks/PSMTabBar/PSMTabBarControl.h | 67 ++++++++++++++++++--------------- Frameworks/PSMTabBar/PSMTabBarControl.m | 25 +++++++++++- 2 files changed, 60 insertions(+), 32 deletions(-) (limited to 'Frameworks/PSMTabBar') diff --git a/Frameworks/PSMTabBar/PSMTabBarControl.h b/Frameworks/PSMTabBar/PSMTabBarControl.h index 663bb74e..481bb3b8 100644 --- a/Frameworks/PSMTabBar/PSMTabBarControl.h +++ b/Frameworks/PSMTabBar/PSMTabBarControl.h @@ -66,53 +66,55 @@ enum { // Spring-loading. NSTimer *_springTimer; - NSTabViewItem *_tabViewItemWithSpring; + NSTabViewItem *_tabViewItemWithSpring; // drawing style id style; - BOOL _canCloseOnlyTab; - BOOL _disableTabClose; - BOOL _hideForSingleTab; - BOOL _showAddTabButton; - BOOL _sizeCellsToFit; - BOOL _useOverflowMenu; - BOOL _alwaysShowActiveTab; - BOOL _allowsScrubbing; - BOOL _useSafariStyleDragging; - NSInteger _resizeAreaCompensation; - PSMTabBarOrientation _orientation; - BOOL _automaticallyAnimates; + BOOL _canCloseOnlyTab; + BOOL _disableTabClose; + BOOL _hideForSingleTab; + BOOL _showAddTabButton; + BOOL _sizeCellsToFit; + BOOL _useOverflowMenu; + BOOL _alwaysShowActiveTab; + BOOL _allowsScrubbing; + BOOL _useSafariStyleDragging; + NSInteger _resizeAreaCompensation; + PSMTabBarOrientation _orientation; + BOOL _automaticallyAnimates; NSTimer *_animationTimer; PSMTabBarTearOffStyle _tearOffStyle; // behavior - BOOL _allowsBackgroundTabClosing; - BOOL _selectsTabsOnMouseDown; - BOOL _createsTabOnDoubleClick; - id _createNewTabTarget; - SEL _createNewTabAction; + BOOL _allowsBackgroundTabClosing; + BOOL _selectsTabsOnMouseDown; + BOOL _createsTabOnDoubleClick; + id _createNewTabTarget; + SEL _createNewTabAction; + id _doubleClickTarget; + SEL _doubleClickAction; // vertical tab resizing - BOOL _allowsResizing; - BOOL _resizing; + BOOL _allowsResizing; + BOOL _resizing; // cell width - NSInteger _cellMinWidth; - NSInteger _cellMaxWidth; - NSInteger _cellOptimumWidth; + NSInteger _cellMinWidth; + NSInteger _cellMaxWidth; + NSInteger _cellOptimumWidth; // animation for hide/show - NSInteger _currentStep; - BOOL _isHidden; + NSInteger _currentStep; + BOOL _isHidden; IBOutlet id partnerView; // gets resized when hide/show - BOOL _awakenedFromNib; - NSInteger _tabBarWidth; + BOOL _awakenedFromNib; + NSInteger _tabBarWidth; NSTimer *_showHideAnimationTimer; // drag and drop - NSEvent *_lastMouseDownEvent; // keep this for dragging reference - BOOL _didDrag; - BOOL _closeClicked; + NSEvent *_lastMouseDownEvent; // keep this for dragging reference + BOOL _didDrag; + BOOL _closeClicked; // MVC help IBOutlet id delegate; @@ -144,6 +146,11 @@ enum { - (SEL)createNewTabAction; - (void)setCreateNewTabAction:(SEL)selector; +- (id)doubleClickTarget; +- (void)setDoubleClickTarget:(id)object; +- (SEL)doubleClickAction; +- (void)setDoubleClickAction:(SEL)selector; + - (NSInteger)cellMinWidth; - (void)setCellMinWidth:(NSInteger)value; - (NSInteger)cellMaxWidth; diff --git a/Frameworks/PSMTabBar/PSMTabBarControl.m b/Frameworks/PSMTabBar/PSMTabBarControl.m index 028dc84b..a38c50b0 100644 --- a/Frameworks/PSMTabBar/PSMTabBarControl.m +++ b/Frameworks/PSMTabBar/PSMTabBarControl.m @@ -471,8 +471,6 @@ [self update]; } - - - (id)createNewTabTarget { return _createNewTabTarget; @@ -495,7 +493,25 @@ [[self addTabButton] setAction:selector]; } +- (id)doubleClickTarget +{ + return _doubleClickTarget; +} + +- (void)setDoubleClickTarget:(id)object +{ + _doubleClickTarget = object; +} + +- (SEL)doubleClickAction +{ + return _doubleClickAction; +} +- (void)setDoubleClickAction:(SEL)selector +{ + _doubleClickAction = selector; +} - (NSInteger)cellMinWidth { @@ -1327,6 +1343,11 @@ [cell setCloseButtonOver:NO]; [cell setCloseButtonPressed:YES]; _closeClicked = YES; + } + else if ([theEvent clickCount] == 2) { + [cell setCloseButtonOver:NO]; + + [_doubleClickTarget performSelector:_doubleClickAction withObject:cell]; } else { [cell setCloseButtonPressed:NO]; if (_selectsTabsOnMouseDown) { -- cgit v1.2.3