- Code: Select all
class CefAppRenderer : public CefApp, public CefRenderProcessHandler:
::OnContextCreated
CefRefPtr<CefV8Value> object = context->GetGlobal();
CefRefPtr<CefV8Handler> handler = new MyV8Handler(browser, &mGuiSheetManagerRenderer);
mGuiSheetManagerRenderer.generateV8Bindings(object, handler);
class GuiSheetManagerRenderer :
::generateV8Bindings(CefRefPtr<CefV8Value> object, CefRefPtr<CefV8Handler> handler) {
for (RendererBindingsMap::iterator it = rbindings.begin(); it != rbindings.end(); it++) {
std::string funcName = it->first; // this string is correct ("test1")
CefRefPtr<CefV8Value> func = CefV8Value::CreateFunction(funcName, handler);
object->SetValue(funcName, func, V8_PROPERTY_ATTRIBUTE_NONE); //object should be the global context
}
class MyV8Handler : public CefV8Handler :
::execute
//not called when javascript is correct
javascript:
<html>
<head>
<script type="text/javascript">
function func1() {
window.test1();
}
</script>
</head>
<body>
<div onclick="func1();" style="background-color:red"> adfasf</div>
</body>
</html>
the mouse/key event is passed as i tested on an inputbox.