mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Remove unused double key press code
Summary: This was added in D3343907 June 1st 2016, disabled in D3428043 June 16, 2016 and never re-enabled. Changelog: [Internal] Reviewed By: shergin Differential Revision: D21635227 fbshipit-source-id: db51dfb6271359bea7da34b4e2a71931fc7c2a63
This commit is contained in:
committed by
Facebook GitHub Bot
parent
6ff6a79dd9
commit
6f75065d82
@@ -12,37 +12,20 @@
|
||||
+ (instancetype)sharedInstance;
|
||||
|
||||
/**
|
||||
* Register a single-press keyboard command.
|
||||
* Register a keyboard command.
|
||||
*/
|
||||
- (void)registerKeyCommandWithInput:(NSString *)input
|
||||
modifierFlags:(UIKeyModifierFlags)flags
|
||||
action:(void (^)(UIKeyCommand *command))block;
|
||||
|
||||
/**
|
||||
* Unregister a single-press keyboard command.
|
||||
* Unregister a keyboard command.
|
||||
*/
|
||||
- (void)unregisterKeyCommandWithInput:(NSString *)input modifierFlags:(UIKeyModifierFlags)flags;
|
||||
|
||||
/**
|
||||
* Check if a single-press command is registered.
|
||||
* Check if a command is registered.
|
||||
*/
|
||||
- (BOOL)isKeyCommandRegisteredForInput:(NSString *)input modifierFlags:(UIKeyModifierFlags)flags;
|
||||
|
||||
/**
|
||||
* Register a double-press keyboard command.
|
||||
*/
|
||||
- (void)registerDoublePressKeyCommandWithInput:(NSString *)input
|
||||
modifierFlags:(UIKeyModifierFlags)flags
|
||||
action:(void (^)(UIKeyCommand *command))block;
|
||||
|
||||
/**
|
||||
* Unregister a double-press keyboard command.
|
||||
*/
|
||||
- (void)unregisterDoublePressKeyCommandWithInput:(NSString *)input modifierFlags:(UIKeyModifierFlags)flags;
|
||||
|
||||
/**
|
||||
* Check if a double-press command is registered.
|
||||
*/
|
||||
- (BOOL)isDoublePressKeyCommandRegisteredForInput:(NSString *)input modifierFlags:(UIKeyModifierFlags)flags;
|
||||
|
||||
@end
|
||||
|
||||
@@ -128,54 +128,6 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Double Press Key Command Response
|
||||
* Double KeyEvent (Double R, etc.)
|
||||
*/
|
||||
- (void)RCT_handleDoublePressKeyCommand:(UIKeyCommand *)key
|
||||
{
|
||||
static BOOL firstPress = YES;
|
||||
static NSTimeInterval lastCommand = 0;
|
||||
static NSTimeInterval lastDoubleCommand = 0;
|
||||
static NSString *lastInput = nil;
|
||||
static UIKeyModifierFlags lastModifierFlags = 0;
|
||||
|
||||
if (firstPress) {
|
||||
for (RCTKeyCommand *command in [RCTKeyCommands sharedInstance].commands) {
|
||||
if ([command.keyCommand.input isEqualToString:key.input] &&
|
||||
command.keyCommand.modifierFlags == key.modifierFlags && command.block) {
|
||||
firstPress = NO;
|
||||
lastCommand = CACurrentMediaTime();
|
||||
lastInput = key.input;
|
||||
lastModifierFlags = key.modifierFlags;
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Second keyevent within 0.2 second,
|
||||
// with the same key as the first one.
|
||||
if (CACurrentMediaTime() - lastCommand < 0.2 && lastInput == key.input && lastModifierFlags == key.modifierFlags) {
|
||||
for (RCTKeyCommand *command in [RCTKeyCommands sharedInstance].commands) {
|
||||
if ([command.keyCommand.input isEqualToString:key.input] &&
|
||||
command.keyCommand.modifierFlags == key.modifierFlags && command.block) {
|
||||
// NOTE: throttle the key handler because on iOS 9 the handleKeyCommand:
|
||||
// method gets called repeatedly if the command key is held down.
|
||||
if (CACurrentMediaTime() - lastDoubleCommand > 0.5) {
|
||||
command.block(key);
|
||||
lastDoubleCommand = CACurrentMediaTime();
|
||||
}
|
||||
firstPress = YES;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lastCommand = CACurrentMediaTime();
|
||||
lastInput = key.input;
|
||||
lastModifierFlags = key.modifierFlags;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation RCTKeyCommands
|
||||
@@ -244,45 +196,6 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init)
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)registerDoublePressKeyCommandWithInput:(NSString *)input
|
||||
modifierFlags:(UIKeyModifierFlags)flags
|
||||
action:(void (^)(UIKeyCommand *))block
|
||||
{
|
||||
RCTAssertMainQueue();
|
||||
|
||||
UIKeyCommand *command = [UIKeyCommand keyCommandWithInput:input
|
||||
modifierFlags:flags
|
||||
action:@selector(RCT_handleDoublePressKeyCommand:)];
|
||||
|
||||
RCTKeyCommand *keyCommand = [[RCTKeyCommand alloc] initWithKeyCommand:command block:block];
|
||||
[_commands removeObject:keyCommand];
|
||||
[_commands addObject:keyCommand];
|
||||
}
|
||||
|
||||
- (void)unregisterDoublePressKeyCommandWithInput:(NSString *)input modifierFlags:(UIKeyModifierFlags)flags
|
||||
{
|
||||
RCTAssertMainQueue();
|
||||
|
||||
for (RCTKeyCommand *command in _commands.allObjects) {
|
||||
if ([command matchesInput:input flags:flags]) {
|
||||
[_commands removeObject:command];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isDoublePressKeyCommandRegisteredForInput:(NSString *)input modifierFlags:(UIKeyModifierFlags)flags
|
||||
{
|
||||
RCTAssertMainQueue();
|
||||
|
||||
for (RCTKeyCommand *command in _commands) {
|
||||
if ([command matchesInput:input flags:flags]) {
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#else
|
||||
@@ -309,21 +222,6 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init)
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)registerDoublePressKeyCommandWithInput:(NSString *)input
|
||||
modifierFlags:(UIKeyModifierFlags)flags
|
||||
action:(void (^)(UIKeyCommand *))block
|
||||
{
|
||||
}
|
||||
|
||||
- (void)unregisterDoublePressKeyCommandWithInput:(NSString *)input modifierFlags:(UIKeyModifierFlags)flags
|
||||
{
|
||||
}
|
||||
|
||||
- (BOOL)isDoublePressKeyCommandRegisteredForInput:(NSString *)input modifierFlags:(UIKeyModifierFlags)flags
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user