EE1D7C9216E01E7000B000EB /* NSView+FirstResponder.m in Sources */ = {isa = PBXBuildFile; fileRef = EE1D7C9116E01E7000B000EB /* NSView+FirstResponder.m */; };
EE1D7C9616E0ECCF00B000EB /* NSError+Description.m in Sources */ = {isa = PBXBuildFile; fileRef = EE1D7C9516E0ECCF00B000EB /* NSError+Description.m */; };
EE96929416E54B480054A3C8 /* NSMenu+RepresentedObjectAccessors.m in Sources */ = {isa = PBXBuildFile; fileRef = EE96929316E54B480054A3C8 /* NSMenu+RepresentedObjectAccessors.m */; };
+ EEAA9CE116E808E600256B64 /* NSMutableArray+MoveObject.m in Sources */ = {isa = PBXBuildFile; fileRef = EEAA9CE016E808E600256B64 /* NSMutableArray+MoveObject.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
EE1D7C9516E0ECCF00B000EB /* NSError+Description.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSError+Description.m"; sourceTree = "<group>"; };
EE96929216E54B480054A3C8 /* NSMenu+RepresentedObjectAccessors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSMenu+RepresentedObjectAccessors.h"; sourceTree = "<group>"; };
EE96929316E54B480054A3C8 /* NSMenu+RepresentedObjectAccessors.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSMenu+RepresentedObjectAccessors.m"; sourceTree = "<group>"; };
+ EEAA9CDF16E808E600256B64 /* NSMutableArray+MoveObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSMutableArray+MoveObject.h"; sourceTree = "<group>"; };
+ EEAA9CE016E808E600256B64 /* NSMutableArray+MoveObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSMutableArray+MoveObject.m"; sourceTree = "<group>"; };
EEF86B7316E2241000674B87 /* NJInputPathElement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NJInputPathElement.h; sourceTree = "<group>"; };
EEF86B7416E298CD00674B87 /* NJEvents.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NJEvents.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
EE1D7C9116E01E7000B000EB /* NSView+FirstResponder.m */,
EE96929216E54B480054A3C8 /* NSMenu+RepresentedObjectAccessors.h */,
EE96929316E54B480054A3C8 /* NSMenu+RepresentedObjectAccessors.m */,
+ EEAA9CDF16E808E600256B64 /* NSMutableArray+MoveObject.h */,
+ EEAA9CE016E808E600256B64 /* NSMutableArray+MoveObject.m */,
);
name = Categories;
sourceTree = "<group>";
EE1D7C9216E01E7000B000EB /* NSView+FirstResponder.m in Sources */,
EE1D7C9616E0ECCF00B000EB /* NSError+Description.m in Sources */,
EE96929416E54B480054A3C8 /* NSMenu+RepresentedObjectAccessors.m in Sources */,
+ EEAA9CE116E808E600256B64 /* NSMutableArray+MoveObject.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
#import "NJOutputController.h"
#import "NJEvents.h"
+#define PB_ROW @"com.yukkurigames.Enjoyable.MappingRow"
+
@implementation NJMappingsController {
NSMutableArray *_mappings;
NJMapping *manualMapping;
return self;
}
+- (void)awakeFromNib {
+ [tableView registerForDraggedTypes:@[PB_ROW]];
+}
+
- (NJMapping *)objectForKeyedSubscript:(NSString *)name {
for (NJMapping *mapping in _mappings)
if ([name isEqualToString:mapping.name])
- (IBAction)addPressed:(id)sender {
NJMapping *newMapping = [[NJMapping alloc] initWithName:@"Untitled"];
[_mappings addObject:newMapping];
- [self mappingsChanged];
[self activateMapping:newMapping];
+ [self mappingsChanged];
[tableView editColumn:0 row:_mappings.count - 1 withEvent:nil select:YES];
}
return;
[_mappings removeObjectAtIndex:tableView.selectedRow];
- [self mappingsChanged];
[self activateMapping:_mappings[0]];
+ [self mappingsChanged];
}
-(void)tableViewSelectionDidChange:(NSNotification *)notify {
[_mappings addObject:mapping];
}
- [self mappingsChanged];
[self activateMapping:mapping];
- [outputController loadCurrent];
+ [self mappingsChanged];
if (conflict && !mergeInto) {
[tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:_mappings.count - 1] byExtendingSelection:NO];
}
}
+- (BOOL)tableView:(NSTableView *)tableView
+ acceptDrop:(id <NSDraggingInfo>)info
+ row:(NSInteger)row
+ dropOperation:(NSTableViewDropOperation)dropOperation {
+ NSPasteboard *pboard = [info draggingPasteboard];
+ if ([pboard.types containsObject:PB_ROW]) {
+ NSString *value = [pboard stringForType:PB_ROW];
+ NSUInteger srcRow = [value intValue];
+ [_mappings moveObjectAtIndex:srcRow toIndex:row];
+ [self mappingsChanged];
+ return YES;
+ } else {
+ return NO;
+ }
+}
+
+- (NSDragOperation)tableView:(NSTableView *)tableView_
+ validateDrop:(id <NSDraggingInfo>)info
+ proposedRow:(NSInteger)row
+ proposedDropOperation:(NSTableViewDropOperation)dropOperation {
+ NSPasteboard *pboard = [info draggingPasteboard];
+ if ([pboard.types containsObject:PB_ROW]) {
+ [tableView_ setDropRow:MAX(1, row) dropOperation:NSTableViewDropAbove];
+ return NSDragOperationGeneric;
+ } else {
+ return NSDragOperationNone;
+ }
+}
+
+- (BOOL)tableView:(NSTableView *)tableView
+writeRowsWithIndexes:(NSIndexSet *)rowIndexes
+ toPasteboard:(NSPasteboard *)pboard {
+ if (rowIndexes.count == 1 && rowIndexes.firstIndex != 0) {
+ [pboard declareTypes:@[PB_ROW] owner:nil];
+ [pboard setString:@(rowIndexes.firstIndex).stringValue forType:PB_ROW];
+ return YES;
+ } else {
+ return NO;
+ }
+
+}
@end