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(); } "];
Community
  • 1
  • 1
Ram
  • 1,872
  • 5
  • 31
  • 54

1 Answers1

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

Community
  • 1
  • 1
Ram
  • 1,872
  • 5
  • 31
  • 54