2

我正在尝试构建一个 MacOS 应用程序,它创建一个 OpenGL 视图并将其作为元素嵌入到 webview 中(使用 OpenGL 而不是 WebGL)。主要目标是使用 web (html/javascript) 作为 UI 并使用 OpenGL 视图绘制结果。(此外,OpenGL 视图也将处理用户输入)

问题是 webview 和 OpenGL 视图之间的覆盖。如果 OpenGL 视图位于 webview 之上,则 webview UI(如:下拉框)可能会被 OpenGL 视图剪切。webview 在 OpenGL 视图之上,所有的 webview 视图都会挡住 OpenGL 视图。

有什么解决方案可以解决这个问题吗?(OpenGL 和 Web 视图)

4

1 回答 1

1

WebKit 有一个有趣的功能,您可以将具有某些 MIME 类型的 webview 关联到您自己的自定义 NSView 类。

在您的 HTML webview 中,您可以放置​​一个具有自定义 mimetype 的 iframe(例如“application/my-custom-view”)。

之后,从您的本机应用程序中,您可以调用:

[WebView registerViewClass:[MyCustomView class] representationClass:[MyCustomRepresentation class] forMIMEType:@"application/my-custom-view"];

请参阅https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Webkit/Classes/WebView_Class/Reference/Reference.html#//apple_ref/occ/clm/WebView/registerViewClass:representationClass:forMIMEType

MyCustomRepresentation 可以非常轻量级,我的 Representation 类不做任何事情,它只是定义了存根委托函数。

于 2013-10-25T00:24:52.500 回答