Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Classes/Manager/FLEXManager+Extensibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ NS_ASSUME_NONNULL_BEGIN
action:(dispatch_block_t)action
description:(NSString *)description;

/// The simulator shortcuts will no-op if there is already a first responder in the window.
/// Sometimes we might want to still allow simulator shortcuts despite this.
/// @param ignoredClassNames Classes that should be ignored by the simulator shortcut manager.
- (void)setSimulatorShortcutIgnoredClassNames:(NSArray<NSString *> *)ignoredClassNames;

@end

NS_ASSUME_NONNULL_END
5 changes: 5 additions & 0 deletions Classes/Manager/FLEXManager+Extensibility.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ - (BOOL)simulatorShortcutsEnabled {
#endif
}

- (void)setSimulatorShortcutIgnoredClassNames:(NSArray<NSString *> *)ignoredClassNames {
#if TARGET_OS_SIMULATOR
[FLEXKeyboardShortcutManager.sharedManager setSimulatorShortcutIgnoredClassNames:ignoredClassNames];
#endif
}

#pragma mark - Shortcuts Defaults

Expand Down
3 changes: 3 additions & 0 deletions Classes/Utility/Keyboard/FLEXKeyboardShortcutManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
description:(NSString *)description
allowOverride:(BOOL)allowOverride;

/// @param ignoredClassNames Classes that should be ignored by the simulator shortcut manager.
- (void)setSimulatorShortcutIgnoredClassNames:(NSArray<NSString *> *)ignoredClassNames;

@property (nonatomic, getter=isEnabled) BOOL enabled;
@property (nonatomic, readonly) NSString *keyboardShortcutsDescription;

Expand Down
13 changes: 10 additions & 3 deletions Classes/Utility/Keyboard/FLEXKeyboardShortcutManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ @interface FLEXKeyboardShortcutManager ()

@end

@implementation FLEXKeyboardShortcutManager
@implementation FLEXKeyboardShortcutManager {
NSArray<NSString *> *_ignoredFirstResponderClassNames;
}

+ (instancetype)sharedManager {
static FLEXKeyboardShortcutManager *sharedManager = nil;
Expand Down Expand Up @@ -222,6 +224,10 @@ - (void)registerSimulatorShortcutWithKey:(NSString *)key
}
}

- (void)setSimulatorShortcutIgnoredClassNames:(NSArray<NSString *> *)ignoredClassNames {
_ignoredFirstResponderClassNames = ignoredClassNames;
}

static const long kFLEXControlKeyCode = 0xe0;
static const long kFLEXShiftKeyCode = 0xe1;
static const long kFLEXCommandKeyCode = 0xe3;
Expand Down Expand Up @@ -257,8 +263,9 @@ - (void)handleKeyboardEvent:(UIEvent *)event {
if (isKeyDown && modifiedInput.length > 0 && interactionEnabled) {
UIResponder *firstResponder = nil;
for (UIWindow *window in FLEXUtility.allWindows) {
firstResponder = [window valueForKey:@"firstResponder"];
if (firstResponder) {
NSString *const className = NSStringFromClass([firstResponder class]);
const BOOL isIgnored = [_ignoredFirstResponderClassNames containsObject:className];
if (firstResponder && !isIgnored) {
hasFirstResponder = YES;
break;
}
Expand Down