https://developer.mozilla.org/en-US/doc ... ustomEvent
This was my inital attempt but the CustomEvent object is never recognised as an Event object by the browser.
- Code: Select all
CefRefPtr<CefV8Value> globalObj = context->GetGlobal();
CefRefPtr<CefV8Value> customEvent = globalObj->GetValue("CustomEvent");
CefRefPtr<CefV8Value> prototype = customEvent->GetValue("prototype");
CefV8ValueList prototypeArgs;
prototypeArgs.push_back(prototype);
prototypeArgs.push_back();
CefRefPtr<CefV8Value> object = globalObj->GetValue("Object");
CefRefPtr<CefV8Value> create = object->GetValue("create");
CefRefPtr<CefV8Value> event = create->ExecuteFunction(NULL, prototypeArgs);
event->SetValue("type", CefV8Value::CreateString(args->GetString(0)), V8_PROPERTY_ATTRIBUTE_NONE);
globalObj->SetValue("taco", event, V8_PROPERTY_ATTRIBUTE_NONE);
CefV8ValueList arguments;
arguments.push_back(event);
CefRefPtr<CefV8Value> dispatchEvent = globalObj->GetValue("dispatchEvent");
dispatchEvent->ExecuteFunction(NULL, arguments);
Actually after trying similar code the browser will only let me create a new one with the new operator. Is there a way to do that from my v8 context?