Skip to content

Commit

Permalink
CB-10376: (ios) Obey KeyboardDisplayRequiresUserAction config setting
Browse files Browse the repository at this point in the history
  • Loading branch information
YetiCGN authored and Jörn Wagner committed Jul 8, 2016
1 parent 1b31d4d commit eb485aa
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/ios/CDVWKWebViewEngine.m
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,19 @@ - (void)updateSettings:(NSDictionary*)settings
}
}

// Fixes CB-10376: Make autofocus work by obeying KeyboardDisplayRequiresUserAction like UIWebView does
BOOL keyboardDisplayRequiresUserAction = [settings cordovaBoolSettingForKey:@"KeyboardDisplayRequiresUserAction" defaultValue:YES];
if (!keyboardDisplayRequiresUserAction) {
SEL sel = sel_getUid("_startAssistingNode:userIsInteracting:blurPreviousNode:userObject:");
Class WKContentView = NSClassFromString(@"WKContentView");
Method method = class_getInstanceMethod(WKContentView, sel);
IMP originalImp = method_getImplementation(method);
IMP imp = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, id arg3)
{ ((void (*)(id, SEL, void*, BOOL, BOOL, id))originalImp)(me, sel, arg0, TRUE, arg2, arg3); }
);
method_setImplementation(method, imp);
}

NSString* decelerationSetting = [settings cordovaSettingForKey:@"WKWebViewDecelerationSpeed"];
if (!decelerationSetting) {
// Fallback to the UIWebView-named preference
Expand Down

0 comments on commit eb485aa

Please sign in to comment.