@@ -1688,108 +1688,91 @@ - (void)draggedImage:(NSImage *)image movedTo:(NSPoint)screenPoint {
1688
1688
1689
1689
// NSDraggingDestination
1690
1690
- (NSDragOperation )draggingEntered : (id <NSDraggingInfo >)sender {
1691
- if (self.window .alphaValue > 0.0 ) {
1692
- if ([[[sender draggingPasteboard ] types ] indexOfObject: @" PSMTabBarControlItemPBType" ] != NSNotFound ) {
1693
- if ([self delegate ] && [[self delegate ] respondsToSelector: @selector (tabView:shouldDropTabViewItem:inTabBar: )] &&
1694
- ![[self delegate ] tabView: [[sender draggingSource ] tabView ] shouldDropTabViewItem: [[[PSMTabDragAssistant sharedDragAssistant ] draggedCell ] representedObject ] inTabBar: self ]) {
1695
- return NSDragOperationNone;
1696
- }
1697
-
1698
- [[PSMTabDragAssistant sharedDragAssistant ] draggingEnteredTabBarControl: self atPoint: [self convertPoint: [sender draggingLocation ] fromView: nil ]];
1699
- return NSDragOperationMove;
1691
+ if ([[[sender draggingPasteboard ] types ] indexOfObject: @" PSMTabBarControlItemPBType" ] != NSNotFound ) {
1692
+ if ([self delegate ] && [[self delegate ] respondsToSelector: @selector (tabView:shouldDropTabViewItem:inTabBar: )] &&
1693
+ ![[self delegate ] tabView: [[sender draggingSource ] tabView ] shouldDropTabViewItem: [[[PSMTabDragAssistant sharedDragAssistant ] draggedCell ] representedObject ] inTabBar: self ]) {
1694
+ return NSDragOperationNone;
1700
1695
}
1696
+
1697
+ [[PSMTabDragAssistant sharedDragAssistant ] draggingEnteredTabBarControl: self atPoint: [self convertPoint: [sender draggingLocation ] fromView: nil ]];
1698
+ return NSDragOperationMove;
1701
1699
}
1702
1700
return NSDragOperationNone;
1703
1701
}
1704
1702
1705
1703
- (NSDragOperation )draggingUpdated : (id <NSDraggingInfo >)sender {
1706
- if (self.window .alphaValue > 0.0 ) {
1707
- PSMTabBarCell *cell = [self cellForPoint: [self convertPoint: [sender draggingLocation ] fromView: nil ] cellFrame: nil ];
1704
+ PSMTabBarCell *cell = [self cellForPoint: [self convertPoint: [sender draggingLocation ] fromView: nil ] cellFrame: nil ];
1708
1705
1709
- if ([[[sender draggingPasteboard ] types ] indexOfObject: @" PSMTabBarControlItemPBType" ] != NSNotFound ) {
1710
- if ([self delegate ] && [[self delegate ] respondsToSelector: @selector (tabView:shouldDropTabViewItem:inTabBar: )] &&
1711
- ![[self delegate ] tabView: [[sender draggingSource ] tabView ] shouldDropTabViewItem: [[[PSMTabDragAssistant sharedDragAssistant ] draggedCell ] representedObject ] inTabBar: self ]) {
1712
- return NSDragOperationNone;
1713
- }
1706
+ if ([[[sender draggingPasteboard ] types ] indexOfObject: @" PSMTabBarControlItemPBType" ] != NSNotFound ) {
1707
+ if ([self delegate ] && [[self delegate ] respondsToSelector: @selector (tabView:shouldDropTabViewItem:inTabBar: )] &&
1708
+ ![[self delegate ] tabView: [[sender draggingSource ] tabView ] shouldDropTabViewItem: [[[PSMTabDragAssistant sharedDragAssistant ] draggedCell ] representedObject ] inTabBar: self ]) {
1709
+ return NSDragOperationNone;
1710
+ }
1714
1711
1715
- [[PSMTabDragAssistant sharedDragAssistant ] draggingUpdatedInTabBarControl: self atPoint: [self convertPoint: [sender draggingLocation ] fromView: nil ]];
1716
- return NSDragOperationMove;
1717
- } else if (cell) {
1718
- // something that was accepted by the delegate was dragged on
1719
-
1720
- // Test for the space bar (the skip-the-delay key).
1721
- /* enum { virtualKeycodeForSpace = 49 }; //Source: IM:Tx (Fig. C-2)
1722
- union {
1723
- KeyMap keymap;
1724
- char bits[16];
1725
- } keymap;
1726
- GetKeys(keymap.keymap);
1727
- if ((GetCurrentEventKeyModifiers() == 0) && bit_test(keymap.bits, virtualKeycodeForSpace)) {
1728
- //The user pressed the space bar. This skips the delay; the user wants to pop the spring on this tab *now*.
1729
-
1730
- //For some reason, it crashes if I call -fire here. I don't know why. It doesn't crash if I simply set the fire date to now.
1731
- [_springTimer setFireDate:[NSDate date]];
1732
- } else {*/
1733
- // Wind the spring for a spring-loaded drop.
1734
- // The delay time comes from Finder's defaults, which specifies it in milliseconds.
1735
- // If the delegate can't handle our spring-loaded drop, we'll abort it when the timer fires. See fireSpring:. This is simpler than constantly (checking for spring-loaded awareness and tearing down/rebuilding the timer) at every delegate change.
1736
-
1737
- // If the user has dragged to a different tab, reset the timer.
1738
- if (_tabViewItemWithSpring != [cell representedObject ]) {
1739
- [_springTimer invalidate ];
1740
- [_springTimer release ]; _springTimer = nil ;
1741
- _tabViewItemWithSpring = [cell representedObject ];
1742
- }
1743
- if (!_springTimer) {
1744
- // Finder's default delay time, as of Tiger, is 668 ms. If the user has never changed it, there's no setting in its defaults, so we default to that amount.
1745
- NSNumber *delayNumber = NSMakeCollectable ([(NSNumber *)CFPreferencesCopyAppValue ((CFStringRef )@" SpringingDelayMilliseconds" , (CFStringRef )@" com.apple.finder" ) autorelease ]);
1746
- NSTimeInterval delaySeconds = delayNumber ?[delayNumber doubleValue ] / 1000.0 : 0.668 ;
1747
- _springTimer = [[NSTimer scheduledTimerWithTimeInterval: delaySeconds
1748
- target: self
1749
- selector: @selector (fireSpring: )
1750
- userInfo: sender
1751
- repeats: NO ] retain ];
1752
- }
1753
- return NSDragOperationCopy;
1712
+ [[PSMTabDragAssistant sharedDragAssistant ] draggingUpdatedInTabBarControl: self atPoint: [self convertPoint: [sender draggingLocation ] fromView: nil ]];
1713
+ return NSDragOperationMove;
1714
+ } else if (cell) {
1715
+ // something that was accepted by the delegate was dragged on
1716
+
1717
+ // Test for the space bar (the skip-the-delay key).
1718
+ /* enum { virtualKeycodeForSpace = 49 }; //Source: IM:Tx (Fig. C-2)
1719
+ union {
1720
+ KeyMap keymap;
1721
+ char bits[16];
1722
+ } keymap;
1723
+ GetKeys(keymap.keymap);
1724
+ if ((GetCurrentEventKeyModifiers() == 0) && bit_test(keymap.bits, virtualKeycodeForSpace)) {
1725
+ //The user pressed the space bar. This skips the delay; the user wants to pop the spring on this tab *now*.
1726
+
1727
+ //For some reason, it crashes if I call -fire here. I don't know why. It doesn't crash if I simply set the fire date to now.
1728
+ [_springTimer setFireDate:[NSDate date]];
1729
+ } else {*/
1730
+ // Wind the spring for a spring-loaded drop.
1731
+ // The delay time comes from Finder's defaults, which specifies it in milliseconds.
1732
+ // If the delegate can't handle our spring-loaded drop, we'll abort it when the timer fires. See fireSpring:. This is simpler than constantly (checking for spring-loaded awareness and tearing down/rebuilding the timer) at every delegate change.
1733
+
1734
+ // If the user has dragged to a different tab, reset the timer.
1735
+ if (_tabViewItemWithSpring != [cell representedObject ]) {
1736
+ [_springTimer invalidate ];
1737
+ [_springTimer release ]; _springTimer = nil ;
1738
+ _tabViewItemWithSpring = [cell representedObject ];
1739
+ }
1740
+ if (!_springTimer) {
1741
+ // Finder's default delay time, as of Tiger, is 668 ms. If the user has never changed it, there's no setting in its defaults, so we default to that amount.
1742
+ NSNumber *delayNumber = NSMakeCollectable ([(NSNumber *)CFPreferencesCopyAppValue ((CFStringRef )@" SpringingDelayMilliseconds" , (CFStringRef )@" com.apple.finder" ) autorelease ]);
1743
+ NSTimeInterval delaySeconds = delayNumber ?[delayNumber doubleValue ] / 1000.0 : 0.668 ;
1744
+ _springTimer = [[NSTimer scheduledTimerWithTimeInterval: delaySeconds
1745
+ target: self
1746
+ selector: @selector (fireSpring: )
1747
+ userInfo: sender
1748
+ repeats: NO ] retain ];
1754
1749
}
1750
+ return NSDragOperationCopy;
1755
1751
}
1756
-
1757
1752
return NSDragOperationNone;
1758
1753
}
1759
1754
1760
1755
- (void )draggingExited : (id <NSDraggingInfo >)sender {
1761
- if (self.window .alphaValue > 0.0 ) {
1762
- [_springTimer invalidate ];
1763
- [_springTimer release ]; _springTimer = nil ;
1756
+ [_springTimer invalidate ];
1757
+ [_springTimer release ]; _springTimer = nil ;
1764
1758
1765
- [[PSMTabDragAssistant sharedDragAssistant ] draggingExitedTabBarControl: self ];
1766
- }
1759
+ [[PSMTabDragAssistant sharedDragAssistant ] draggingExitedTabBarControl: self ];
1767
1760
}
1768
1761
1769
1762
- (BOOL )prepareForDragOperation : (id <NSDraggingInfo >)sender {
1770
- if (self.window .alphaValue > 0.0 ) {
1771
- // validate the drag operation only if there's a valid tab bar to drop into
1772
- return [[[sender draggingPasteboard ] types ] indexOfObject: @" PSMTabBarControlItemPBType" ] == NSNotFound ||
1773
- [[PSMTabDragAssistant sharedDragAssistant ] destinationTabBar ] != nil ;
1774
- }
1775
- return NO ;
1763
+ // validate the drag operation only if there's a valid tab bar to drop into
1764
+ return [[[sender draggingPasteboard ] types ] indexOfObject: @" PSMTabBarControlItemPBType" ] == NSNotFound ||
1765
+ [[PSMTabDragAssistant sharedDragAssistant ] destinationTabBar ] != nil ;
1776
1766
}
1777
1767
1778
1768
- (BOOL )performDragOperation : (id <NSDraggingInfo >)sender {
1779
- if (self.window .alphaValue > 0.0 ) {
1780
- if ([[[sender draggingPasteboard ] types ] indexOfObject: @" PSMTabBarControlItemPBType" ] != NSNotFound ) {
1781
- [[PSMTabDragAssistant sharedDragAssistant ] performDragOperation ];
1782
- } else if ([self delegate ] && [[self delegate ] respondsToSelector: @selector (tabView:acceptedDraggingInfo:onTabViewItem: )]) {
1783
- // forward the drop to the delegate
1784
- [[self delegate ] tabView: tabView acceptedDraggingInfo: sender onTabViewItem: [[self cellForPoint: [self convertPoint: [sender draggingLocation ] fromView: nil ] cellFrame: nil ] representedObject ]];
1785
- }
1786
- return YES ;
1769
+ if ([[[sender draggingPasteboard ] types ] indexOfObject: @" PSMTabBarControlItemPBType" ] != NSNotFound ) {
1770
+ [[PSMTabDragAssistant sharedDragAssistant ] performDragOperation ];
1771
+ } else if ([self delegate ] && [[self delegate ] respondsToSelector: @selector (tabView:acceptedDraggingInfo:onTabViewItem: )]) {
1772
+ // forward the drop to the delegate
1773
+ [[self delegate ] tabView: tabView acceptedDraggingInfo: sender onTabViewItem: [[self cellForPoint: [self convertPoint: [sender draggingLocation ] fromView: nil ] cellFrame: nil ] representedObject ]];
1787
1774
}
1788
- return NO ;
1789
- }
1790
-
1791
- - (BOOL )wantsPeriodicDraggingUpdates {
1792
- return NO ;
1775
+ return YES ;
1793
1776
}
1794
1777
1795
1778
- (void )draggedImage : (NSImage *)anImage endedAt : (NSPoint )aPoint operation : (NSDragOperation )operation {
0 commit comments