3 @implementation ITTabView
5 - (id)initWithFrame:(NSRect)frame
7 if ( (self = [super initWithFrame:frame]) ) {
13 - (void)mouseDown:(NSEvent *)event
15 NSPoint clickedPoint = [self convertPoint:[event locationInWindow] fromView:[[self window] contentView]];
16 NSTabViewItem *clickedTab = [self tabViewItemAtPoint:clickedPoint];
17 _draggedTab = clickedTab;
18 [super mouseDown:event];
21 - (void)mouseUp:(NSEvent *)event
23 NSPoint releasedPoint = [self convertPoint:[event locationInWindow] fromView:[[self window] contentView]];
24 NSTabViewItem *releasedTab = [self tabViewItemAtPoint:releasedPoint];
25 if (releasedTab && ![releasedTab isEqualTo:_draggedTab]) {
26 int releasedTabIndex = [self indexOfTabViewItem:releasedTab];
28 [self removeTabViewItem:_draggedTab];
29 [self insertTabViewItem:_draggedTab atIndex:releasedTabIndex];
30 [self selectTabViewItem:_draggedTab];
33 [super mouseUp:event];
36 - (void)mouseDragged:(NSEvent *)event
38 NSPoint currentPoint = [self convertPoint:[event locationInWindow] fromView:[[self window] contentView]];
39 NSTabViewItem *curTab = [self tabViewItemAtPoint:currentPoint];
40 if (curTab && ![curTab isEqualTo:_draggedTab]) {
41 int curTabIndex = [self indexOfTabViewItem:curTab];
43 [self removeTabViewItem:_draggedTab];
44 [self insertTabViewItem:_draggedTab atIndex:curTabIndex];
45 [self selectTabViewItem:_draggedTab];
47 [super mouseDragged:event];