-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUCTableView.m
More file actions
58 lines (46 loc) · 1.19 KB
/
UCTableView.m
File metadata and controls
58 lines (46 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//
// UCTableView.m
// Chain
//
// Created by Christoph on 13.06.2009.
// Copyright 2009 Useless Coding. All rights reserved.
//
#import "UCTableView.h"
@implementation UCTableView
- (void)keyDown:(NSEvent *)theEvent
{
if([[theEvent charactersIgnoringModifiers] length])
{
unichar key = [[theEvent charactersIgnoringModifiers] characterAtIndex:0];
if(key==NSDeleteFunctionKey || key==NSDeleteCharacter || key==NSDeleteCharFunctionKey)
{
[self doCommandBySelector:@selector(delete:)];
return;
}
}
[super keyDown:theEvent];
}
- (IBAction)delete:(id)sender
{
id ds = [self dataSource];
if([self selectedRow]!=-1 && [ds respondsToSelector:@selector(tableView:deleteRowsWithIndexes:)])
{
[ds tableView:self deleteRowsWithIndexes:[self selectedRowIndexes]];
[self deselectAll:self];
[self reloadData];
}
}
- (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)anItem
{
if([anItem action]==@selector(delete:))
{
return [self selectedRow]!=-1;
}
return [super validateUserInterfaceItem:anItem];
}
@end
@implementation NSObject (UCTableViewDataSource)
- (void)tableView:(UCTableView *)aTableView deleteRowsWithIndexes:(NSIndexSet *)rowIndexes
{
}
@end