projects
/
enjoyable.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Replace hacky target stringification with structured serialization.
[enjoyable.git]
/
TargetMouseScroll.m
diff --git
a/TargetMouseScroll.m
b/TargetMouseScroll.m
index
79bc542
..
3c417c1
100644
(file)
--- a/
TargetMouseScroll.m
+++ b/
TargetMouseScroll.m
@@
-12,22
+12,25
@@
@synthesize howMuch;
@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,
-(void) trigger {
CGEventRef scroll = CGEventCreateScrollWheelEvent(NULL,
kCGScrollEventUnitLine,
1,
-
[self howMuch]
);
+
self.howMuch
);
CGEventPost(kCGHIDEventTap, scroll);
CFRelease(scroll);
}
CGEventPost(kCGHIDEventTap, scroll);
CFRelease(scroll);
}