0

Before I deem my weak-long custom re-implementation of UITextView (using an UIWebView in designMode) useless, is there any way to handle/cancel javaScript onKeyUp, etc. events?

AFAIK there is only messaging via -shouldLoadRequest: & stringByEvaluatingScriptWithString:. However, these calls are asynchronous and the javaScript event handler has already exited it's function by the time stringByEvaluatingScriptWithString: is performed thus event cancellation methods do not work.

If not for this capability, implementing shouldReplaceCharactersInString: seems impossible. :(

0

1 Answer 1

1

Maybe you can check my open source implementation of a "safari like" browser : https://github.com/sylverb/CIALBrowser

In this one, I did reimplement the long tap handling, and to disable the standard one, I use this :

- (void) webViewDidFinishLoad:(UIWebView *) sender
{
    // Disable the defaut actionSheet when doing a long press
    [webView stringByEvaluatingJavaScriptFromString:@"document.body.style.webkitTouchCallout='none';"];
    [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitTouchCallout='none';"];
}
Sign up to request clarification or add additional context in comments.

3 Comments

Sorry for the delay. I thought I set SO to send me email updates but I never received any. I'll try to look over this tomorrow.
Thanks for your response. I believe in your case you basically disconnected the js event handler and instead handled iOS touch event natively.
In my case iOS doesn't allow key events to be handled natively so that wouldn't work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.