2008-06-21 05:25:38 +00:00
|
|
|
//
|
|
|
|
// FileTreeOutlineView.m
|
|
|
|
// Cog
|
|
|
|
//
|
|
|
|
// Created by Vincent Spader on 6/21/08.
|
|
|
|
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2013-10-03 08:00:58 +00:00
|
|
|
#import "FileTreeController.h"
|
2008-06-21 05:25:38 +00:00
|
|
|
#import "FileTreeOutlineView.h"
|
|
|
|
#import "FileTreeViewController.h"
|
2009-08-16 16:49:34 +00:00
|
|
|
#import "PlaybackController.h"
|
2008-06-21 05:25:38 +00:00
|
|
|
|
|
|
|
@implementation FileTreeOutlineView
|
|
|
|
|
|
|
|
- (void)awakeFromNib
|
|
|
|
{
|
2021-01-27 02:30:19 +00:00
|
|
|
[self setDoubleAction:@selector(addToPlaylistExternal:)];
|
|
|
|
[self setTarget:[self delegate]];
|
2008-06-21 05:25:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)keyDown:(NSEvent *)e
|
|
|
|
{
|
2021-01-27 02:30:19 +00:00
|
|
|
unsigned int modifiers = [e modifierFlags] & (NSEventModifierFlagCommand | NSEventModifierFlagShift | NSEventModifierFlagControl | NSEventModifierFlagOption);
|
2008-06-21 05:25:38 +00:00
|
|
|
NSString *characters = [e characters];
|
2021-01-27 02:30:19 +00:00
|
|
|
unichar c;
|
|
|
|
|
|
|
|
if ([characters length] == 1)
|
|
|
|
{
|
|
|
|
c = [characters characterAtIndex:0];
|
|
|
|
|
|
|
|
if (modifiers == 0 && (c == NSEnterCharacter || c == NSCarriageReturnCharacter))
|
|
|
|
{
|
|
|
|
[(FileTreeController *)[self delegate] addToPlaylistExternal:self];
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (modifiers == 0 && c == ' ')
|
|
|
|
{
|
|
|
|
[(FileTreeController *)[self delegate] playPauseResume:self];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[super keyDown:e];
|
|
|
|
|
|
|
|
return;
|
2008-06-21 05:25:38 +00:00
|
|
|
}
|
|
|
|
|
2009-08-16 16:49:34 +00:00
|
|
|
// enables right-click selection for "Show in Finder" contextual menu
|
|
|
|
-(NSMenu*)menuForEvent:(NSEvent*)event
|
|
|
|
{
|
2021-01-27 02:30:19 +00:00
|
|
|
//Find which row is under the cursor
|
|
|
|
[[self window] makeFirstResponder:self];
|
|
|
|
NSPoint menuPoint = [self convertPoint:[event locationInWindow] fromView:nil];
|
|
|
|
NSInteger iRow = [self rowAtPoint:menuPoint];
|
|
|
|
NSMenu* contextMenu = [self menu];
|
|
|
|
|
|
|
|
/* Update the file tree selection before showing menu
|
|
|
|
Preserves the selection if the row under the mouse is selected (to allow for
|
|
|
|
multiple items to be selected), otherwise selects the row under the mouse */
|
|
|
|
BOOL currentRowIsSelected = [[self selectedRowIndexes] containsIndex:iRow];
|
|
|
|
|
|
|
|
if (iRow == -1)
|
|
|
|
{
|
|
|
|
[self deselectAll:self];
|
|
|
|
}
|
|
|
|
else if (!currentRowIsSelected)
|
|
|
|
{
|
|
|
|
[self selectRowIndexes:[NSIndexSet indexSetWithIndex:iRow] byExtendingSelection:NO];
|
|
|
|
}
|
|
|
|
|
|
|
|
return contextMenu;
|
2009-08-16 16:49:34 +00:00
|
|
|
}
|
|
|
|
|
2008-06-21 05:25:38 +00:00
|
|
|
@end
|