Allow clicking on the key field directly.
[enjoyable.git] / Config.m
index f62c40f..5a83ed3 100644 (file)
--- a/Config.m
+++ b/Config.m
@@ -7,23 +7,29 @@
 
 #import "Config.h"
 
-@implementation Config
+#import "JSAction.h"
 
-@synthesize protect, name, entries;
+@implementation Config
 
-- (id)init {
+- (id)initWithName:(NSString *)name {
     if ((self = [super init])) {
-        entries = [[NSMutableDictionary alloc] init];
+        self.name = name;
+        _entries = [[NSMutableDictionary alloc] init];
     }
     return self;
 }
 
-- (void)setTarget:(Target *)target forAction:(JSAction *)jsa {
-    entries[[jsa stringify]] = target;
+- (Target *)objectForKeyedSubscript:(JSAction *)action {
+    return action ? _entries[action.uid] : nil;
 }
 
-- (Target *)getTargetForAction:(JSAction *)jsa {
-    return entries[[jsa stringify]];
+- (void)setObject:(Target *)target forKeyedSubscript:(JSAction *)action {
+    if (action) {
+        if (target)
+            _entries[action.uid] = target;
+        else
+            [_entries removeObjectForKey:action.uid];
+    }
 }
 
 @end