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.
|
|
|
|
//
|
|
|
|
|
|
|
|
#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
|
|
|
|
{
|
|
|
|
[self setDoubleAction:@selector(addToPlaylist:)];
|
|
|
|
[self setTarget:[self delegate]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)keyDown:(NSEvent *)e
|
|
|
|
{
|
|
|
|
unsigned int modifiers = [e modifierFlags] & (NSCommandKeyMask | NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask);
|
|
|
|
NSString *characters = [e characters];
|
|
|
|
unichar c;
|
|
|
|
|
|
|
|
if ([characters length] == 1)
|
|
|
|
{
|
|
|
|
c = [characters characterAtIndex:0];
|
|
|
|
|
|
|
|
if (modifiers == 0 && (c == NSEnterCharacter || c == NSCarriageReturnCharacter))
|
|
|
|
{
|
|
|
|
[[self delegate] addToPlaylist:self];
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2009-08-16 16:49:34 +00:00
|
|
|
else if (modifiers == 0 && c == ' ')
|
|
|
|
{
|
|
|
|
[[self delegate] playPauseResume:self];
|
|
|
|
return;
|
|
|
|
}
|
2008-06-21 05:25:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[super keyDown:e];
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-08-16 16:49:34 +00:00
|
|
|
// enables right-click selection for "Show in Finder" contextual menu
|
|
|
|
-(NSMenu*)menuForEvent:(NSEvent*)event
|
|
|
|
{
|
|
|
|
//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 selectRow:iRow byExtendingSelection:NO];
|
|
|
|
}
|
|
|
|
|
|
|
|
return contextMenu;
|
|
|
|
}
|
|
|
|
|
2008-06-21 05:25:38 +00:00
|
|
|
@end
|