X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=TargetController.m;h=7a4fd058e470d6238dd5b285d3a03770129e0c41;hp=a7dbd2c6535bb89e75e108d9d66196f54455f74c;hb=44a44209d4ce26fb30102014d7040975aea51f93;hpb=60710a84810cfbfa39ada9a9e44f61ceb2f144c5 diff --git a/TargetController.m b/TargetController.m index a7dbd2c..7a4fd05 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]; @@ -211,10 +216,15 @@ - (void)refreshConfigs { // TODO: This doesn't work when removing configs. - int initialIndex = configPopup.indexOfSelectedItem; - [configPopup removeAllItems]; - for (Config *config in configsController.configs) - [configPopup addItemWithTitle:config.name]; + NSInteger initialIndex = configPopup.indexOfSelectedItem; + [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]; }