X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=NJOutputSwitchMouseMode.m;fp=NJOutputSwitchMouseMode.m;h=3332a91118c0a81bb00c39a73819065e9fdc0744;hp=0000000000000000000000000000000000000000;hb=dcedf147ddcb6c21768cea94a2f06b93007d2a82;hpb=e2a4d830dd9817f6a515a3b1b6aa152d3bb98c2b diff --git a/NJOutputSwitchMouseMode.m b/NJOutputSwitchMouseMode.m new file mode 100644 index 0000000..3332a91 --- /dev/null +++ b/NJOutputSwitchMouseMode.m @@ -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