Rewrite KeyInputTextView into NJKeyInputField. New class communicates using a proper...
[enjoyable.git] / TargetController.m
index 1f285ec..48119c2 100644 (file)
@@ -11,7 +11,7 @@
 #import "Config.h"
 #import "JSAction.h"
 #import "JoystickController.h"
-#import "KeyInputTextView.h"
+#import "NJKeyInputField.h"
 #import "TargetConfig.h"
 #import "TargetController.h"
 #import "TargetKeyboard.h"
@@ -26,7 +26,7 @@
     NSInteger row = radioButtons.selectedRow;
     
     if (row != 1) {
-        keyInput.vk = -1;
+        keyInput.keyCode = -1;
         [keyInput resignIfFirstResponder];
     }
     
     [self commit];
 }
 
-- (void)keyChanged {
+- (void)keyInputField:(NJKeyInputField *)keyInput didChangeKey:(CGKeyCode)keyCode {
     [radioButtons selectCellAtRow:1 column:0];
     [radioButtons.window makeFirstResponder:radioButtons];
     [self commit];
 }
 
+- (void)keyInputFieldDidClear:(NJKeyInputField *)keyInput {
+    [radioButtons selectCellAtRow:0 column:0];
+    [self commit];
+}
+
 - (void)configChosen:(id)sender {
     [radioButtons selectCellAtRow:2 column:0];
     [configPopup.window makeFirstResponder:configPopup];
         case 0:
             return nil;
         case 1:
-            if (keyInput.hasKey) {
+            if (keyInput.hasKeyCode) {
                 TargetKeyboard *k = [[TargetKeyboard alloc] init];
-                k.vk = keyInput.vk;
+                k.vk = keyInput.keyCode;
                 return k;
             } else {
                 return nil;
 
     if ([target isKindOfClass:TargetKeyboard.class]) {
         [radioButtons selectCellAtRow:1 column:0];
-        keyInput.vk = [(TargetKeyboard*)target vk];
+        keyInput.keyCode = [(TargetKeyboard*)target vk];
     } else if ([target isKindOfClass:TargetConfig.class]) {
         [radioButtons selectCellAtRow:2 column:0];
         NSUInteger idx = [configsController.configs