mirror of
https://github.com/keycastr/keycastr.git
synced 2026-05-15 06:06:06 -06:00
Rename to -[KCKeystroke isCommand]
... which is true with the command *or* control key Also renane the local variables related to modifier keys for clarity
This commit is contained in:
parent
91165edcb0
commit
98474daed6
5 changed files with 16 additions and 17 deletions
|
|
@ -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];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (BOOL)isCommandKey {
|
||||
- (BOOL)isCommand {
|
||||
return (self.modifierFlags & (NSEventModifierFlagControl | NSEventModifierFlagCommand)) != 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@
|
|||
|
||||
- (void)noteKeyEvent:(KCKeystroke *)keystroke
|
||||
{
|
||||
if (!_displayAll && ![keystroke isCommandKey])
|
||||
if (!_displayAll && ![keystroke isCommand])
|
||||
return;
|
||||
[_visualizerView noteKeyEvent:keystroke];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue