X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=TargetController.m;h=2ecb06057f80e90a909de3616713302d47a6af40;hp=9aad491d17eb41a936d21e08f37e4eda7ef781fe;hb=5bbd1edf2c0cc46fab98f712171a68f9182b0670;hpb=62aa5b73be6ec1e499e6b155cd0e7687c338cbaa diff --git a/TargetController.m b/TargetController.m index 9aad491..2ecb060 100644 --- a/TargetController.m +++ b/TargetController.m @@ -175,8 +175,13 @@ keyInput.vk = [(TargetKeyboard*)target vk]; } else if ([target isKindOfClass:[TargetConfig class]]) { [radioButtons selectCellAtRow:2 column:0]; - [configPopup selectItemAtIndex:[configsController.configs - indexOfObject:[(TargetConfig *)target config]]]; + NSUInteger idx = [configsController.configs + indexOfObject:[(TargetConfig *)target config]]; + if (idx == NSNotFound) { + [radioButtons selectCellAtRow:self.enabled ? 0 : -1 column:0]; + [configPopup selectItemAtIndex:-1]; + } else + [configPopup selectItemAtIndex:idx]; } else if ([target isKindOfClass:[TargetMouseMove class]]) { [radioButtons selectCellAtRow:3 column:0]; @@ -210,11 +215,15 @@ } - (void)refreshConfigs { - // TODO: This doesn't work when removing configs. NSInteger initialIndex = configPopup.indexOfSelectedItem; - [configPopup removeAllItems]; - for (Config *config in configsController.configs) - [configPopup addItemWithTitle:config.name]; + [configPopup.menu removeAllItems]; + for (Config *config in configsController.configs) { + NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:config.name + action:@selector(configChosen:) + keyEquivalent:@""]; + item.target = self; + [configPopup.menu addItem:item]; + } [configPopup selectItemAtIndex:initialIndex]; }