[Mono-osx] WebView WindowScriptObject

Clay Fowler paul.clay.fowler at gmail.com
Fri Feb 25 12:28:50 EST 2011


The Export attribute indeed fixed the problem. Thanks very much! It looks
like there's still some discussion as to whether or not to do the patch,
though?

On Fri, Feb 25, 2011 at 9:12 AM, Geoff Norton <gnorton at novell.com> wrote:

> It appears we dont have the WebScripting protocol bound as a [Model] yet:
>
>
> http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/WebKit/Protocols/WebScripting_Protocol/Reference/Reference.html
>
>
> <http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/WebKit/Protocols/WebScripting_Protocol/Reference/Reference.html>If
> we did you would want to have your NativeMessageReceiver inherit from
> WebScripting and override the methods.
>
> Would you like to submit a patch to the webkit bindings that does this?
>
> In the mean time you can use
>
> [Export ("isSelectorExcludedFromWebScript:")]
> static bool IsSelectorExcluded (Selector s) {
>   return false;
> }
> On 2011-02-25, at 11:01 AM, Clay Fowler wrote:
>
> Is anyone successfully using WindowScriptObject in WebView to have
> Javascript communicate with your C# classes in a MonoMac project? I'm trying
> to do things like this:
>
> ...
>
> webView.WindowScriptObject.SetValueForKey(new NativeMessageReceiver(),new
> NSString("NativeMessageReceiver"));
>
> ...
>
> NSString handleMessage(NSString messageText)
> {
>  Console.Out.WriteLine("Got message from page [" + messageText + "]");
> return new NSString("OK");
>  }
>
> bool isSelectorExcludedFromWebScript(Selector s)
> {
>  return false;
> }
>
> But "isSelectorExcludedFromWebScript" and "handleMessage" never get called.
>
> Any tips?
> _______________________________________________
> Mono-osx mailing list
> Mono-osx at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-osx
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-osx/attachments/20110225/6a97c42c/attachment-0001.html 


More information about the Mono-osx mailing list