0
[scriptObject evaluateWebScript:@"mouseClickCallBack =  function() { SampleWebViewApp. mouseClickCallBack(); } "];

I have a WebView and I am able to capture the mouseEvents using JavaScript. Now I want to insert textarea at the mouse clicked position,for that I have to add the textarea, I would like to add it in the Objective C.How would I notify the events from JavaScript to Objective C.This is for MAC OSX (cocoa) not for iPhone. What delegates of the webview should I use to accomplish this?

Please suggest any alternative to accomplish the same ?

I have gone through this link.

How to call Objective-C from Javascript? But it is for UIWebView

I implemented the following API of WebView

+ (BOOL)isSelectorExcludedFromWebScript:(SEL)selector
{
    if ((selector == @selector(mouseClickCallBack)) 
    {
        return NO;
    }
    return YES;
}

But I am not sure where should I call the following code for mouseClick.

WebScriptObject *scriptObject;
   [scriptObject evaluateWebScript:@"mouseClickCallBack =  function() { SampleWebViewApp.mouseClickCallBack(); } "];

1 Answer 1

0

I am able to solve this issue using alerts in JavaScript and these alerts are handled in WebView UIDelegate.

- (void)webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame

Please refer the following link.

JavaScript alert() not working in embedded WebView

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.