Skip to content

Commit d04362b

Browse files
Pieter de Biepieter
authored andcommitted
History fileview: select current item on rightclick
1 parent ad2213c commit d04362b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

PBQLOutlineView.m

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,25 @@ - (NSArray *)outlineView:(NSOutlineView *)outlineView namesOfPromisedFilesDroppe
5858
return fileNames;
5959
}
6060

61+
- (NSMenu *)menuForEvent:(NSEvent *)theEvent
62+
{
63+
if ([theEvent type] == NSRightMouseDown)
64+
{
65+
// get the current selections for the outline view.
66+
NSIndexSet *selectedRowIndexes = [self selectedRowIndexes];
67+
68+
// select the row that was clicked before showing the menu for the event
69+
NSPoint mousePoint = [self convertPoint:[theEvent locationInWindow] fromView:nil];
70+
int row = [self rowAtPoint:mousePoint];
71+
72+
// figure out if the row that was just clicked on is currently selected
73+
if ([selectedRowIndexes containsIndex:row] == NO)
74+
[self selectRow:row byExtendingSelection:NO];
75+
}
76+
77+
return [super menuForEvent:theEvent];
78+
}
79+
6180
/* Implemented to satisfy datasourcee protocol */
6281
- (BOOL) outlineView: (NSOutlineView *)ov
6382
isItemExpandable: (id)item { return NO; }

0 commit comments

Comments
 (0)