Save after deleting a config. Reset target to no-op when deleting its config, rather...
[enjoyable.git] / TargetController.m
index 86fe968..7a4fd05 100644 (file)
         keyInput.vk = [(TargetKeyboard*)target vk];
     } else if ([target isKindOfClass:[TargetConfig class]]) {
         [radioButtons selectCellAtRow:2 column:0];
         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];
     }
     else if ([target isKindOfClass:[TargetMouseMove class]]) {
         [radioButtons selectCellAtRow:3 column:0];