[webkit-help] How to raise asynchronous events from C++ to JavaScript

Programming Newbie newbie.programming at yahoo.com
Fri Jan 18 12:24:25 PST 2013


Hi,



I have managed to expose C++ APIs to JS using JavaScriptCore and I am able to issue callbacks from JavaScript to C++.

Now, I wanted to raise certain events in C++ and hoping them to be received in JavaScript.

So, if in JS, someone has added code:

myElement.addEventListener("myEvent", myEventHandler(), ...)

Then, I should somehow be able to raise myEvent from C++ and want it to be passed to JavaScript(caught in JS), so that myEventHandler() gets called.

Firstly, I thought of creating callbacks for all event handler functions and calling correct event handler them from C++ whenever an event needs to be raised.
But, if I do like it, then I need to know beforehand which event handlers are associated with which events and I can't register and deregister events on the fly.

Also, there might be more than one handler associated with some events.

JavaScript code is not mine, I have to work with already written scripts and not allowed to modify them. So, I have to find out some way to do it through c++ only.

Can anyone please expain to me, how I can do this.

Thanks,
newbie.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-help/attachments/20130118/44e6fe9e/attachment.html>


More information about the webkit-help mailing list