Remove event translation menu item, it's not managed here anymore. Change NJKeyInputT...
authorJoe Wreschnig <joe.wreschnig@gmail.com>
Mon, 11 Mar 2013 11:17:26 +0000 (12:17 +0100)
committerJoe Wreschnig <joe.wreschnig@gmail.com>
Mon, 11 Mar 2013 11:17:26 +0000 (12:17 +0100)
Classes/NJDeviceController.h
Classes/NJDeviceController.m
Classes/NJKeyInputField.h
Classes/NJKeyInputField.m
Info.plist
Resources/English.lproj/MainMenu.xib

index e668b0f6167b1e30ca9cc075c44913dc1366f1ff..c0002e8ad88dd380aeda689ed8f78e02239ea48e 100644 (file)
@@ -16,7 +16,6 @@
     IBOutlet NJOutputController *outputController;
     IBOutlet NJMappingsController *mappingsController;
     IBOutlet NSButton *translatingEventsButton;
-    IBOutlet NSMenuItem *translatingEventsMenu;
     IBOutlet NSView *connectDevicePrompt;
 }
 
@@ -24,6 +23,6 @@
 @property (nonatomic, assign) NSPoint mouseLoc;
 @property (nonatomic, assign) BOOL translatingEvents;
 
-- (IBAction)translatingEventsChanged:(id)sender;
+- (IBAction)translatingEventsChanged:(NSButton *)sender;
 
 @end
index 5a6603c9bac55f5ffc92572e41971d2232d290c8..3f0c6c8cce86f7c9468c9baa45c34a5c050892f2 100644 (file)
@@ -240,7 +240,6 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
         _translatingEvents = translatingEvents;
         NSInteger state = translatingEvents ? NSOnState : NSOffState;
         translatingEventsButton.state = state;
-        translatingEventsMenu.title = translatingEvents ? @"Disable" : @"Enable";
         NSString *name = translatingEvents
             ? NJEventTranslationActivated
             : NJEventTranslationDeactivated;
@@ -253,5 +252,4 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
     self.translatingEvents = sender.state == NSOnState;
 }
 
-
 @end
index ad026d3f4f0cb163f936f44d20bf727911fb8e99..9a7a3af9863cd3b86322ec8ea0cf856faf413b4e 100644 (file)
@@ -20,7 +20,7 @@ extern CGKeyCode NJKeyInputFieldEmpty;
 + (NSString *)stringForKeyCode:(CGKeyCode)keyCode;
     // Give the string name for a virtual key code.
 
-@property (nonatomic, weak) IBOutlet id <NJKeyInputFieldDelegate> keyDelegate;
+@property (nonatomic, weak) IBOutlet id <NJKeyInputFieldDelegate, NSTextFieldDelegate> delegate;
 
 @property (nonatomic, assign) CGKeyCode keyCode;
     // The currently displayed key code, or NJKeyInputFieldEmpty if no
@@ -37,6 +37,7 @@ extern CGKeyCode NJKeyInputFieldEmpty;
 
 @protocol NJKeyInputFieldDelegate <NSObject>
 
+@optional
 - (void)keyInputField:(NJKeyInputField *)keyInput
          didChangeKey:(CGKeyCode)keyCode;
 - (void)keyInputFieldDidClear:(NJKeyInputField *)keyInput;
index 814fdfe9ee1bfe7b1aa50817ac44a55f3fd5179c..a03f23830d5272758f29ae4320bc9d031f48b643 100644 (file)
@@ -22,7 +22,8 @@ CGKeyCode NJKeyInputFieldEmpty = 0xFFFF;
 
 - (void)clear {
     self.keyCode = NJKeyInputFieldEmpty;
-    [self.keyDelegate keyInputFieldDidClear:self];
+    if ([self.delegate respondsToSelector:@selector(keyInputFieldDidClear:)])
+        [self.delegate keyInputFieldDidClear:self];
     [self resignIfFirstResponder];
 }
 
@@ -179,10 +180,12 @@ CGKeyCode NJKeyInputFieldEmpty = 0xFFFF;
         if ((event.modifierFlags & IGNORE) && event.keyCode == 0x33) {
             // Allow Alt/Command+Backspace to clear the field.
             self.keyCode = NJKeyInputFieldEmpty;
-            [self.keyDelegate keyInputFieldDidClear:self];
+            if ([self.delegate respondsToSelector:@selector(keyInputFieldDidClear:)])
+                [self.delegate keyInputFieldDidClear:self];
         } else if (!(event.modifierFlags & IGNORE)) {
             self.keyCode = event.keyCode;
-            [self.keyDelegate keyInputField:self didChangeKey:self.keyCode];
+            if ([self.delegate respondsToSelector:@selector(keyInputField:didChangeKey:)])
+                [self.delegate keyInputField:self didChangeKey:self.keyCode];
         }
         [self resignIfFirstResponder];
     }
@@ -204,8 +207,17 @@ CGKeyCode NJKeyInputFieldEmpty = 0xFFFF;
     // modifiers are still down.
     if (!(theEvent.modifierFlags & NSDeviceIndependentModifierFlagsMask)) {
         self.keyCode = theEvent.keyCode;
-        [self.keyDelegate keyInputField:self didChangeKey:_keyCode];
+        if ([self.delegate respondsToSelector:@selector(keyInputField:didChangeKey:)])
+            [self.delegate keyInputField:self didChangeKey:_keyCode];
     }
 }
 
+- (void)setDelegate:(id<NJKeyInputFieldDelegate, NSTextFieldDelegate>)delegate {
+    [super setDelegate:delegate];
+}
+
+- (id <NJKeyInputFieldDelegate, NSTextFieldDelegate>)delegate {
+    return (id)[super delegate];
+}
+
 @end
index 74f12656ebfdf7bf617f77d8d5d3c23caf3bd663..42233338c6d1fbcd6f7f5161e66a1db0f5bc6d65 100644 (file)
@@ -46,7 +46,7 @@
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
-       <string>124</string>
+       <string>129</string>
        <key>LSApplicationCategoryType</key>
        <string>public.app-category.utilities</string>
        <key>NSHumanReadableCopyright</key>
index 0a2018693b56001f01b9f607fb0a9f1e5601ca2b..c66656500fd97d38013b8bbbfb56068efcf3bef7 100644 (file)
@@ -524,7 +524,7 @@ aW5nLg</string>
                                                                                                        <string key="NSFrameSize">{232, 321}</string>
                                                                                                        <reference key="NSSuperview" ref="698362889"/>
                                                                                                        <reference key="NSWindow"/>
-                                                                                                       <reference key="NSNextKeyView" ref="1036252745"/>
+                                                                                                       <reference key="NSNextKeyView" ref="892486973"/>
                                                                                                        <bool key="NSEnabled">YES</bool>
                                                                                                        <bool key="NSAllowsLogicalLayoutDirection">NO</bool>
                                                                                                        <bool key="NSControlAllowsExpansionToolTips">YES</bool>
@@ -654,7 +654,7 @@ aW5nLg</string>
                                                                        <string key="NSFrameSize">{234, 323}</string>
                                                                        <reference key="NSSuperview" ref="734312853"/>
                                                                        <reference key="NSWindow"/>
-                                                                       <reference key="NSNextKeyView" ref="892486973"/>
+                                                                       <reference key="NSNextKeyView" ref="698362889"/>
                                                                        <int key="NSsFlags">150034</int>
                                                                        <reference key="NSVScroller" ref="1036252745"/>
                                                                        <reference key="NSHScroller" ref="892486973"/>
@@ -1615,14 +1615,6 @@ aW5nLg</string>
                                        </object>
                                        <int key="connectionID">826</int>
                                </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">translatingEventsMenu</string>
-                                               <reference key="source" ref="1007832501"/>
-                                               <reference key="destination" ref="632598200"/>
-                                       </object>
-                                       <int key="connectionID">877</int>
-                               </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBActionConnection" key="connection">
                                                <string key="label">translatingEventsChanged:</string>
@@ -1977,11 +1969,11 @@ aW5nLg</string>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
-                                               <string key="label">keyDelegate</string>
+                                               <string key="label">delegate</string>
                                                <reference key="source" ref="57697638"/>
                                                <reference key="destination" ref="801536542"/>
                                        </object>
-                                       <int key="connectionID">818</int>
+                                       <int key="connectionID">966</int>
                                </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBActionConnection" key="connection">
@@ -3161,7 +3153,7 @@ aW5nLg</string>
                        <nil key="activeLocalization"/>
                        <dictionary class="NSMutableDictionary" key="localizations"/>
                        <nil key="sourceID"/>
-                       <int key="maxID">965</int>
+                       <int key="maxID">966</int>
                </object>
                <object class="IBClassDescriber" key="IBDocument.Classes">
                        <array class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -3228,7 +3220,6 @@ aW5nLg</string>
                                                <string key="outlineView">NSOutlineView</string>
                                                <string key="outputController">NJOutputController</string>
                                                <string key="translatingEventsButton">NSButton</string>
-                                               <string key="translatingEventsMenu">NSMenuItem</string>
                                        </dictionary>
                                        <dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
                                                <object class="IBToOneOutletInfo" key="connectDevicePrompt">
@@ -3251,10 +3242,6 @@ aW5nLg</string>
                                                        <string key="name">translatingEventsButton</string>
                                                        <string key="candidateClassName">NSButton</string>
                                                </object>
-                                               <object class="IBToOneOutletInfo" key="translatingEventsMenu">
-                                                       <string key="name">translatingEventsMenu</string>
-                                                       <string key="candidateClassName">NSMenuItem</string>
-                                               </object>
                                        </dictionary>
                                        <object class="IBClassDescriptionSource" key="sourceIdentifier">
                                                <string key="majorKey">IBProjectSource</string>
@@ -3265,13 +3252,13 @@ aW5nLg</string>
                                        <string key="className">NJKeyInputField</string>
                                        <string key="superclassName">NSTextField</string>
                                        <object class="NSMutableDictionary" key="outlets">
-                                               <string key="NS.key.0">keyDelegate</string>
+                                               <string key="NS.key.0">delegate</string>
                                                <string key="NS.object.0">id</string>
                                        </object>
                                        <object class="NSMutableDictionary" key="toOneOutletInfosByName">
-                                               <string key="NS.key.0">keyDelegate</string>
+                                               <string key="NS.key.0">delegate</string>
                                                <object class="IBToOneOutletInfo" key="NS.object.0">
-                                                       <string key="name">keyDelegate</string>
+                                                       <string key="name">delegate</string>
                                                        <string key="candidateClassName">id</string>
                                                </object>
                                        </object>