You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.1 KiB
53 lines
1.1 KiB
// |
|
// SRKeyEquivalentTransformer.m |
|
// ShortcutRecorder |
|
// |
|
// Copyright 2012 Contributors. All rights reserved. |
|
// |
|
// License: BSD |
|
// |
|
// Contributors: |
|
// Ilya Kulakov |
|
|
|
#import "SRKeyEquivalentTransformer.h" |
|
#import "SRKeyCodeTransformer.h" |
|
#import "SRRecorderControl.h" |
|
|
|
|
|
@implementation SRKeyEquivalentTransformer |
|
|
|
#pragma mark NSValueTransformer |
|
|
|
+ (BOOL)allowsReverseTransformation |
|
{ |
|
return NO; |
|
} |
|
|
|
+ (Class)transformedValueClass |
|
{ |
|
return [NSString class]; |
|
} |
|
|
|
- (NSString *)transformedValue:(NSDictionary *)aValue |
|
{ |
|
if (![aValue isKindOfClass:[NSDictionary class]]) |
|
return @""; |
|
|
|
NSNumber *keyCode = aValue[SRShortcutKeyCode]; |
|
|
|
if (![keyCode isKindOfClass:[NSNumber class]]) |
|
return @""; |
|
|
|
NSNumber *modifierFlags = aValue[SRShortcutModifierFlagsKey]; |
|
|
|
if (![modifierFlags isKindOfClass:[NSNumber class]]) |
|
modifierFlags = @(0); |
|
|
|
SRKeyCodeTransformer *t = [SRKeyCodeTransformer sharedASCIITransformer]; |
|
|
|
return [t transformedValue:keyCode |
|
withImplicitModifierFlags:nil |
|
explicitModifierFlags:modifierFlags]; |
|
} |
|
|
|
@end
|
|
|