Merge commit 'origin/jg/tree_context'
[GitX.git] / PBUnsortableTableHeader.m
blob9afb8eb78e96eceb0044ac8cfedc400f7795c376
1 //
2 //  PBUnsortableTableHeader.m
3 //  GitX
4 //
5 //  Created by Pieter de Bie on 03-10-08.
6 //  Copyright 2008 __MyCompanyName__. All rights reserved.
7 //
9 #import "PBUnsortableTableHeader.h"
12 @implementation PBUnsortableTableHeader
14 - (void)mouseDown:(NSEvent *)theEvent
16         NSPoint location = [self convertPoint:[[self window] mouseLocationOutsideOfEventStream] fromView:[[self window] contentView]];
17         int aColumnIndex = [self columnAtPoint:location];
19         // If the user pressed on another column, reset
20         if (aColumnIndex != columnIndex)
21         {
22                 clickCount = 1;
23                 columnIndex = aColumnIndex;
24                 [super mouseDown:theEvent];
25                 return;
26         }
28         // On the third click, reset the sorting and
29         // Don't pass on the click
30         if (++clickCount == 3)
31         {
32                 clickCount = 0;
33                 controller.sortDescriptors = [NSArray array];
34                 [controller rearrangeObjects];
35                 return;
36         }
37         [super mouseDown:theEvent];
39 @end