-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTabTableView.j
48 lines (42 loc) · 1.38 KB
/
TabTableView.j
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
@import <AppKit/CPTableView.j>
@import <AppKit/CPTextField.j>
@implementation TabTableView : CPTableView
{
}
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super initWithCoder:aCoder];
if (self)
{
[self setAllowsColumnSelection:NO];
}
[[CPNotificationCenter defaultCenter]
addObserver:self
selector:@selector(textFieldFocused:)
name:CPTextFieldDidFocusNotification
object:nil];
return self;
}
- (void)textFieldFocused:(CPNotification)aNotification {
var currentTextField = [aNotification object];
[[CPNotificationCenter defaultCenter]
addObserver:self
selector:@selector(textFieldBlured:)
name:CPTextFieldDidBlurNotification
object:currentTextField];
}
- (void)textFieldBlured:(CPNotification)aNotification {
var currentTextField = [aNotification object];
var columnNr = [self columnAtPoint:[currentTextField center]] + 1; // got the next column with +1
var tableColumns = [self tableColumns];
var selectedRow = [self selectedRow];
if (columnNr >= [tableColumns count]) {
columnNr = columnNr - 1; // stay at current column
}
[self editColumn:columnNr row:selectedRow withEvent:nil select:YES];
[[CPNotificationCenter defaultCenter]
removeObserver:self
name:CPTextFieldDidBlurNotification
object:currentTextField];
}
@end