forked from ttscoff/nv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTagEditingManager.m
110 lines (90 loc) · 2.48 KB
/
TagEditingManager.m
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//
// TagEditingManager.m
// Notation
//
// Created by elasticthreads on 10/15/10.
//
#import "TagEditingManager.h"
#import "AppController.h"
@implementation TagEditingManager
@synthesize commonTags;
@synthesize tagFieldString;
- (id)initWithDelegate:(id)del commonTags:(NSArray *)cTags atPoint:(NSPoint)centerpoint{
if ((self=[super init])) {
if (![NSBundle loadNibNamed:@"TagEditingManager" owner:self]) {
NSLog(@"Failed to load TagEditer.nib");
}else{
isHappening = YES;
NSRect zRect=[tagPanel frame];
centerpoint.x-=(zRect.size.width/2.0);
centerpoint.y-=(zRect.size.height+70.0);
[tagPanel setDelegate:self];
[tagField setDelegate:del];
self.commonTags=cTags;
[tagPanel setFrameOrigin:centerpoint];
[tagPanel makeKeyAndOrderFront:del];
}
}
return self;
}
- (void)dealloc{
[tagFieldString release];
[commonTags release];
[tagPanel release];
[tagField release];
[super dealloc];
}
- (void)setCommonTags:(NSArray *)newTags{
if (commonTags) {
[commonTags release];
commonTags=nil;
}
commonTags=[newTags retain];
if (isHappening) {
NSString *newTagString=@"";
if (commonTags&&([commonTags count]>0)) {
newTagString=[commonTags componentsJoinedByString:@","];
}
self.tagFieldString=newTagString;
}else{
self.tagFieldString=@"";
}
}
//- (void)awakeFromNib {
// [tagField setStringValue:@""];
//// [tagField setDelegate:self];
//}
//- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command{
// if (command == @selector(cancelOperation:)) {
// [tagPanel orderOut:self];
// //[self closeTP:self];
// }
// return NO;
//}
- (void)cancelOperation:(id)sender {
[tagPanel orderOut:nil];
}
- (void)windowDidResignKey:(NSNotification *)notification{
if ([tagPanel isVisible]) {
[tagPanel orderOut:nil];
}
isHappening = NO;
self.commonTags=[NSArray array];
[[NSNotificationCenter defaultCenter]postNotificationName:@"TagEditorShouldRelease" object:nil];
}
- (void)setTF:(NSString *)inString{
[tagField setStringValue:inString];
}
- (void)closeTP:(id)sender{
[tagPanel orderOut:nil];
}
- (NSTextView *)tagFieldEditor{
return (NSTextView *)[tagPanel fieldEditor:YES forObject:tagField];
}
- (NSTextField *)tagField{
return tagField;
}
- (BOOL)isMultitagging{
return isHappening;
}
@end