简体   繁体   English

单击Web对象后回叫

[英]Call back after a click on web object

I am working on a Winforms application. 我正在开发Winforms应用程序。 We have to display and manipulate a 3D Object that is created and maintained in a Cityengine server somewhere, and the images are served via the internet (kind of like a Google Map 3D). 我们必须显示和操纵在某个地方的Cityengine服务器中创建和维护的3D对象,并且图像是通过互联网提供的(类似于Google Map 3D)。 We are using Awesomium to display the 3D images since it is the only one that seems to handle WebGL well. 我们使用Awesomium来显示3D图像,因为它似乎是唯一能够很好地处理WebGL的图像。

I want my client to be able to click on some of the 3D objects and after that I want my desktop application to also respond to the click. 我希望我的客户能够点击某些3D对象,然后我希望我的桌面应用程序也能对点击做出响应。 In other words, I need the Awesomium to have a call back so when the event executes in 3D image immediately notifies the application. 换句话说,我需要Awesomium进行回叫,以便当事件以3D图像执行时立即通知应用程序。 How can I do that? 我怎样才能做到这一点?

You can create a JavaScript binding that allows you to call C# code from JavaScript. 您可以创建一个JavaScript绑定,该绑定允许您从JavaScript调用C#代码。

Something like: 就像是:

JSObject interfaceBinding = webView.CreateGlobalJavascriptObject("bindingObject");
interfaceBinding.Bind("myFunction", false, myHandler);

With your hander function looking simular to something like this: 通过您的hander函数,看起来类似于以下内容:

private void myHandler(object sender, JavascriptMethodEventArgs e)
{
    //do whatever you want with e.Arguments containg the arguments from the js call
}

This will create an object called 'bindingObject' as global JavaScript object and you can call it with 这将创建一个名为“ bindingObject”的对象作为全局JavaScript对象,您可以使用

window.bindingObject.myFunction(yourParmeters,...);

EDIT: The click event is of course handled in JavaScript in the web view and I just assume you know how to do it, if not (and there is no high-level api): search the web for 'webGL picking' to learn about the different possible approaches (for example color-picking, ray-picking, etc) that can be used in webGL. 编辑:click事件当然是在Web视图中的JavaScript中处理的,我只是假设您知道该怎么做(如果没有)(并且没有高级api):在Web上搜索“ webGL picking”以了解可以在webGL中使用的各种可能的方法(例如,拾色,射线拾取等)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM