Big rename part 3: 'target' to 'output'.
[enjoyable.git] / NJOutputSwitchMouseMode.m
diff --git a/NJOutputSwitchMouseMode.m b/NJOutputSwitchMouseMode.m
new file mode 100644 (file)
index 0000000..3332a91
--- /dev/null
@@ -0,0 +1,35 @@
+//
+//  NJOutputSwitchMouseMode.m
+//  Enjoy
+//
+//  Created by Yifeng Huang on 7/28/12.
+//
+
+#import "NJOutputSwitchMouseMode.h"
+
+#import "ApplicationController.h"
+#import "NJInputController.h"
+
+@implementation NJOutputSwitchMouseMode
+
++ (NSString *)serializationCode {
+    return @"switch mouse mode";
+}
+
+- (NSDictionary *)serialize {
+    return @{ @"type": @"switch mouse mode" };
+}
+
++ (NJOutput *)outputDeserialize:(NSDictionary *)serialization
+                  withMappings:(NSArray *)mappings {
+    return [[NJOutputSwitchMouseMode alloc] init];
+}
+- (void)trigger {
+    // FIXME: It's hacky to get at the controller this way, but it's
+    // also hacky to pass it. Shouldn't need to do either.
+    ApplicationController *ac = NSApplication.sharedApplication.delegate;
+    NJInputController *jc = ac.inputController;
+    jc.frontWindowOnly = !jc.frontWindowOnly;
+}
+
+@end