From b7b7d33597354037b53a9c8bc1931dcd2d4566ff Mon Sep 17 00:00:00 2001 From: Christophe Serafin Date: Mon, 25 Mar 2013 13:22:43 +0100 Subject: [PATCH] avoid to call the delegate when moving before the first column and after the last column --- AppKit/CPTableHeaderView.j | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/AppKit/CPTableHeaderView.j b/AppKit/CPTableHeaderView.j index a3c7dad06..c9a041ae9 100644 --- a/AppKit/CPTableHeaderView.j +++ b/AppKit/CPTableHeaderView.j @@ -505,6 +505,7 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal - (void)_moveColumn:(int)aFromIndex toColumn:(int)aToIndex { + console.log("_moveColumn"); if ([_tableView _shouldReorderColumn:aFromIndex toColumn:aToIndex]) { [_tableView moveColumn:aFromIndex toColumn:aToIndex]; @@ -546,18 +547,21 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal var hoveredColumn = [self columnAtPoint:hoverPoint]; - if (hoveredColumn !== _lastDragDestinationColumnIndex) + if (hoveredColumn !== _lastDragDestinationColumnIndex && hoveredColumn !== -1) { + var columnRect = [self headerRectOfColumn:hoveredColumn], columnCenterPoint = [self convertPoint:CGPointMake(_CGRectGetMidX(columnRect), _CGRectGetMidY(columnRect)) fromView:self]; if (hoveredColumn < _activeColumn && hoverPoint.x < columnCenterPoint.x) { + console.log(hoveredColumn + " " +_activeColumn); [self _moveColumn:_activeColumn toColumn:hoveredColumn]; _lastDragDestinationColumnIndex = hoveredColumn; } else if (hoveredColumn > _activeColumn && hoverPoint.x > columnCenterPoint.x) { + console.log(hoveredColumn + " " +_activeColumn); [self _moveColumn:_activeColumn toColumn:hoveredColumn]; _lastDragDestinationColumnIndex = hoveredColumn; }