X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=NJOutputController.m;h=ed8fe2df6f74e0f6c3304a39317f4d803c558475;hp=f05c615ddc7dd0b10f17e69c766507208e824e74;hb=1315dd378437c84891c795c9927ff40d42d74cb3;hpb=dcedf147ddcb6c21768cea94a2f06b93007d2a82 diff --git a/NJOutputController.m b/NJOutputController.m index f05c615..ed8fe2d 100644 --- a/NJOutputController.m +++ b/NJOutputController.m @@ -10,7 +10,7 @@ #import "NJMappingsController.h" #import "NJMapping.h" #import "NJInput.h" -#import "NJInputController.h" +#import "NJDeviceController.h" #import "NJKeyInputField.h" #import "NJOutputMapping.h" #import "NJOutputController.h" @@ -26,7 +26,7 @@ NSInteger row = radioButtons.selectedRow; if (row != 1) { - keyInput.keyCode = -1; + keyInput.keyCode = NJKeyInputFieldEmpty; [keyInput resignIfFirstResponder]; } @@ -116,7 +116,7 @@ break; case 2: { NJOutputMapping *c = [[NJOutputMapping alloc] init]; - c.mapping = mappingsController.mappings[mappingPopup.indexOfSelectedItem]; + c.mapping = mappingsController[mappingPopup.indexOfSelectedItem]; return c; } case 3: { @@ -172,7 +172,7 @@ for (id cur = input.base; cur; cur = cur.base) { inpFullName = [[NSString alloc] initWithFormat:@"%@ > %@", cur.name, inpFullName]; } - title.stringValue = [[NSString alloc] initWithFormat:@"%@ > %@", mappingsController.currentMapping.name, inpFullName]; + title.stringValue = inpFullName; } if ([output isKindOfClass:NJOutputKeyPress.class]) { @@ -180,8 +180,7 @@ keyInput.keyCode = [(NJOutputKeyPress*)output vk]; } else if ([output isKindOfClass:NJOutputMapping.class]) { [radioButtons selectCellAtRow:2 column:0]; - NSUInteger idx = [mappingsController.mappings - indexOfObject:[(NJOutputMapping *)output mapping]]; + NSUInteger idx = [mappingPopup indexOfItemWithRepresentedObject:[(NJOutputMapping *)output mapping]]; if (idx == NSNotFound) { [radioButtons selectCellAtRow:self.enabled ? 0 : -1 column:0]; [mappingPopup selectItemAtIndex:-1]; @@ -220,16 +219,17 @@ } - (void)refreshMappings { - NSInteger initialIndex = mappingPopup.indexOfSelectedItem; + NJMapping *current = mappingPopup.selectedItem.representedObject; [mappingPopup.menu removeAllItems]; - for (NJMapping *mapping in mappingsController.mappings) { + for (NJMapping *mapping in mappingsController) { NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:mapping.name action:@selector(mappingChosen:) keyEquivalent:@""]; item.target = self; + item.representedObject = mapping; [mappingPopup.menu addItem:item]; } - [mappingPopup selectItemAtIndex:initialIndex]; + [mappingPopup selectItemAtIndex:[mappingPopup indexOfItemWithRepresentedObject:current]]; } @end