From 057e95091e3de6b2b6a9e9f35f70909c348d728e Mon Sep 17 00:00:00 2001
From: Nathan Kinsinger <[email protected]>
Date: Fri, 19 Feb 2010 22:54:25 -0700
Subject: [PATCH] Bugfix: fix the contextual menu and drag-n-drop of refs

When the Subject column is not the first column in the git history table the 
contextual menu for refs and dragging and dropping refs don't work.

Offset the mouse click's x value by the x origin of the Subject column.

In PBRefController look up the column index of the subject column and check 
that it's the clicked column (don't assume it's the first one).
---
 PBCommitList.m      |    3 ++-
 PBGitRevisionCell.m |    2 +-
 PBRefController.m   |    6 ++++--
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/PBCommitList.m b/PBCommitList.m
index 9f76422..264b5e2 100644
--- a/PBCommitList.m
+++ b/PBCommitList.m
@@ -61,8 +61,9 @@
        int row = [self rowAtPoint:location];
        int column = [self columnAtPoint:location];
        PBGitRevisionCell *cell = (PBGitRevisionCell *)[self 
preparedCellAtColumn:column row:row];
+       NSRect cellFrame = [self frameOfCellAtColumn:column row:row];
 
-       int index = [cell indexAtX:location.x];
+       int index = [cell indexAtX:(location.x - cellFrame.origin.x)];
        if (index == -1)
                return [super dragImageForRowsWithIndexes:dragRows 
tableColumns:tableColumns event:dragEvent offset:dragImageOffset];
 
diff --git a/PBGitRevisionCell.m b/PBGitRevisionCell.m
index 98f978b..579168b 100644
--- a/PBGitRevisionCell.m
+++ b/PBGitRevisionCell.m
@@ -283,7 +283,7 @@
        if (!contextMenuDelegate)
                return [self menu];
 
-       int i = [self indexAtX:[view convertPointFromBase:[event 
locationInWindow]].x];
+       int i = [self indexAtX:[view convertPointFromBase:[event 
locationInWindow]].x - rect.origin.x];
        if (i < 0)
                return [self menu];
 
diff --git a/PBRefController.m b/PBRefController.m
index 31c5590..f25d7e8 100644
--- a/PBRefController.m
+++ b/PBRefController.m
@@ -92,12 +92,14 @@
        NSPoint location = [tv convertPointFromBase:[(PBCommitList *)tv 
mouseDownPoint]];
        int row = [tv rowAtPoint:location];
        int column = [tv columnAtPoint:location];
-       if (column != 0)
+       int subjectColumn = [tv columnWithIdentifier:@"SubjectColumn"];
+       if (column != subjectColumn)
                return NO;
        
        PBGitRevisionCell *cell = (PBGitRevisionCell *)[tv 
preparedCellAtColumn:column row:row];
+       NSRect cellFrame = [tv frameOfCellAtColumn:column row:row];
        
-       int index = [cell indexAtX:location.x];
+       int index = [cell indexAtX:(location.x - cellFrame.origin.x)];
        
        if (index == -1)
                return NO;
-- 
1.7.0+GitX



Reply via email to