X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=TargetMouseScroll.m;fp=TargetMouseScroll.m;h=3c417c1264a56576d0d4d2870af97d219acfdbb3;hp=79bc5421f371bfe97e6aecd24882e183247a810d;hb=0a402879ee3beb79bb4d2270f909ad75eead0c96;hpb=c6fb77859e508aaef686b7a5a6a12abe29178708 diff --git a/TargetMouseScroll.m b/TargetMouseScroll.m index 79bc542..3c417c1 100644 --- a/TargetMouseScroll.m +++ b/TargetMouseScroll.m @@ -12,22 +12,25 @@ @synthesize howMuch; --(NSString*) stringify { - return [[NSString alloc] initWithFormat: @"mscroll~%d", howMuch]; ++ (NSString *)serializationCode { + return @"mscroll"; } -+(TargetMouseScroll*) unstringifyImpl: (NSArray*) comps { - NSParameterAssert([comps count] == 2); - TargetMouseScroll* target = [[TargetMouseScroll alloc] init]; - [target setHowMuch: [comps[1] integerValue]]; - return target; +- (NSDictionary *)serialize { + return @{ @"type": @"mscroll", @"howMuch": @(self.howMuch) }; } ++ (Target *)targetDeserialize:(NSDictionary *)serialization + withConfigs:(NSArray *)configs { + TargetMouseScroll *target = [[TargetMouseScroll alloc] init]; + target.howMuch = [serialization[@"howMuch"] intValue]; + return target; +} -(void) trigger { CGEventRef scroll = CGEventCreateScrollWheelEvent(NULL, kCGScrollEventUnitLine, 1, - [self howMuch]); + self.howMuch); CGEventPost(kCGHIDEventTap, scroll); CFRelease(scroll); }