diff --git a/keycastr/KCDefaultVisualizer.m b/keycastr/KCDefaultVisualizer.m index 4b04201..fd0931a 100644 --- a/keycastr/KCDefaultVisualizer.m +++ b/keycastr/KCDefaultVisualizer.m @@ -158,7 +158,7 @@ static const CGFloat kKCDefaultBezelPadding = 10.0; - (void)noteKeyEvent:(KCKeystroke *)keystroke { - if (![keystroke isCommandKey] && [self shouldOnlyDisplayCommandKeys]) { + if (![keystroke isCommand] && [self shouldOnlyDisplayCommandKeys]) { return; } @@ -310,7 +310,7 @@ static NSRect KC_defaultFrame(void) { { [self _cancelLineBreak]; - if ([keystroke isCommandKey]) + if ([keystroke isCommand]) { [self abandonCurrentBezelView]; } diff --git a/keycastr/KCEventTransformer.m b/keycastr/KCEventTransformer.m index 397f825..5227012 100644 --- a/keycastr/KCEventTransformer.m +++ b/keycastr/KCEventTransformer.m @@ -46,7 +46,7 @@ } static NSString* kCommandKeyString = @"\xe2\x8c\x98"; -static NSString* kAltKeyString = @"\xe2\x8c\xa5"; +static NSString* kOptionKeyString = @"\xe2\x8c\xa5"; static NSString* kControlKeyString = @"\xe2\x8c\x83"; static NSString* kShiftKeyString = @"\xe2\x87\xa7"; static NSString* kLeftTabString = @"\xe2\x87\xa4"; @@ -161,8 +161,8 @@ static NSString* kLeftTabString = @"\xe2\x87\xa4"; - (id)transformedValue:(KCKeycastrEvent *)event { NSEventModifierFlags _modifiers = event.modifierFlags; - BOOL isOption = _modifiers & NSEventModifierFlagOption; - BOOL isShifted = _modifiers & NSEventModifierFlagShift; + BOOL hasOptionModifier = _modifiers & NSEventModifierFlagOption; + BOOL hasShiftModifier = _modifiers & NSEventModifierFlagShift; BOOL needsShiftGlyph = NO; @@ -175,16 +175,16 @@ static NSString* kLeftTabString = @"\xe2\x87\xa4"; [mutableResponse appendString:kControlKeyString]; } - if (isOption && ([event isKindOfClass:[KCKeystroke class]] && [(KCKeystroke *)event isCommandKey])) + if (hasOptionModifier && ([event isKindOfClass:[KCKeystroke class]] && [(KCKeystroke *)event isCommand])) { - [mutableResponse appendString:kAltKeyString]; + [mutableResponse appendString:kOptionKeyString]; } - if (isShifted) + if (hasShiftModifier) { if (_modifiers & (NSEventModifierFlagControl | NSEventModifierFlagCommand)) [mutableResponse appendString:kShiftKeyString]; - else if (isOption && !displayModifiedKeyWhenOptionPressed) + else if (hasOptionModifier && !displayModifiedKeyWhenOptionPressed) [mutableResponse appendString:kShiftKeyString]; else needsShiftGlyph = !displayModifiedKeyWhenOptionPressed; @@ -211,10 +211,9 @@ static NSString* kLeftTabString = @"\xe2\x87\xa4"; KCKeystroke *keystroke = (KCKeystroke *)event; uint16_t _keyCode = keystroke.keyCode; - BOOL isCommandKey = keystroke.isCommandKey; // check for bare shift-tab as left tab special case - if (isShifted && !isCommandKey && !isOption) + if (hasShiftModifier && !keystroke.isCommand && !hasOptionModifier) { if ([@(_keyCode) isEqualToNumber:@48]) { [mutableResponse appendString:kLeftTabString]; @@ -234,13 +233,13 @@ static NSString* kLeftTabString = @"\xe2\x87\xa4"; return mutableResponse; } - if (displayModifiedKeyWhenOptionPressed && !keystroke.isCommandKey) { + if (displayModifiedKeyWhenOptionPressed && !keystroke.isCommand) { [mutableResponse appendString:keystroke.characters]; } else { [mutableResponse appendString:[self translatedCharacterForKeystroke:keystroke]]; } - if (isCommandKey || isShifted) + if (keystroke.isCommand || hasShiftModifier) { mutableResponse = [[[mutableResponse uppercaseString] mutableCopy] autorelease]; } diff --git a/keycastr/KCKeystroke.h b/keycastr/KCKeystroke.h index 6056c31..b57666f 100644 --- a/keycastr/KCKeystroke.h +++ b/keycastr/KCKeystroke.h @@ -36,8 +36,8 @@ @property (nonatomic, copy, readonly) NSString *characters; @property (nonatomic, copy, readonly) NSString *charactersIgnoringModifiers; -/// A Keystroke is a command key if it includes a Control or Command key; Option and Shift are only considered modifiers. -- (BOOL)isCommandKey; +/// A Keystroke is a command if it includes the Control or Command key; Option and Shift are only considered modifiers. +- (BOOL)isCommand; /// Indicates whether a Keystroke has any of the Control, Command, Option or Shift modifiers applied. - (BOOL)isModified; diff --git a/keycastr/KCKeystroke.m b/keycastr/KCKeystroke.m index ed590c6..98fda52 100644 --- a/keycastr/KCKeystroke.m +++ b/keycastr/KCKeystroke.m @@ -57,7 +57,7 @@ [super dealloc]; } -- (BOOL)isCommandKey { +- (BOOL)isCommand { return (self.modifierFlags & (NSEventModifierFlagControl | NSEventModifierFlagCommand)) != 0; } diff --git a/keycastr/SvelteVisualizer.m b/keycastr/SvelteVisualizer.m index acce5bf..71973ea 100644 --- a/keycastr/SvelteVisualizer.m +++ b/keycastr/SvelteVisualizer.m @@ -238,7 +238,7 @@ - (void)noteKeyEvent:(KCKeystroke *)keystroke { - if (!_displayAll && ![keystroke isCommandKey]) + if (!_displayAll && ![keystroke isCommand]) return; [_visualizerView noteKeyEvent:keystroke]; }