1/* 2 Project: MPDCon 3 4 Copyright (C) 2004 5 6 Author: Daniel Luederwald 7 8 Created: 2004-05-17 23:17:38 +0200 by flip 9 10 This application is free software; you can redistribute it and/or 11 modify it under the terms of the GNU General Public 12 License as published by the Free Software Foundation; either 13 version 2 of the License, or (at your option) any later version. 14 15 This application is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 Library General Public License for more details. 19 20 You should have received a copy of the GNU General Public 21 License along with this library; if not, write to the Free 22 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. 23*/ 24 25#include <AppKit/AppKit.h> 26#include "OwnTableView.h" 27 28@implementation OwnTableView 29 30/* -------------------- 31 - Delegate Methods - 32 --------------------*/ 33 34 - (NSImage*) dragImageForRows: (NSArray*)dragRows 35 event: (NSEvent*)dragEvent 36 dragImageOffset: (NSPoint*)dragImageOffset 37{ 38 return [NSImage imageNamed: @"MoveSong"]; 39} 40 41- (void) selectAll: (id) sender 42{ 43 [super selectAll: sender]; 44 [self setNeedsDisplay: YES]; 45} 46 47- (void) keyDown: (NSEvent *) theEvent 48{ 49 NSString *characters = [theEvent characters]; 50 unichar character = 0; 51 52 if ([characters length] > 0) 53 { 54 character = [characters characterAtIndex: 0]; 55 } 56 57 switch (character) 58 { 59 case NSUpArrowFunctionKey: 60 { 61 int row = [self selectedRow]; 62 63 if (row > 0) 64 { 65 [self selectRow: row-1 byExtendingSelection: NO]; 66 [self scrollRowToVisible: row-1]; 67 } 68 break; 69 } 70 case NSDownArrowFunctionKey: 71 { 72 int row = [self selectedRow]; 73 int maxRow = [self numberOfRows]; 74 75 if (row < maxRow-1) 76 { 77 [self selectRow: row+1 byExtendingSelection: NO]; 78 [self scrollRowToVisible: row+1]; 79 } 80 break; 81 } 82 case NSHomeFunctionKey: 83 { 84 if ([self numberOfRows] > 0) 85 { 86 [self selectRow: 0 byExtendingSelection: NO]; 87 [self scrollRowToVisible: 0]; 88 } 89 break; 90 } 91 case NSEndFunctionKey: 92 { 93 int rows = [self numberOfRows]; 94 95 if (rows > 0) 96 { 97 [self selectRow: rows-1 byExtendingSelection: NO]; 98 [self scrollRowToVisible: rows-1]; 99 } 100 break; 101 } 102 case '\r': 103 { 104 [[self target] performSelector: [self doubleAction]]; 105 break; 106 } 107 default: 108 [super keyDown: theEvent]; 109 break; 110 } 111} 112@end 113