I can think of two ways to do this.
You can add an accessor to CppObjects that gets called whenever a
value is assigned to 'onmousedown'. It creates a persistent handle to
the object and stores it in the c++ object. When there is a mousedown
event in c++ you can check if an event handler has been stored and
call it if there is one.
Alternatively you can store a reference to the javascript object
itself in the c++ object and look up the 'onmousedown' property
whenever an event occurs. If the property contains a function you
call it. This gives you a bit more overhead when there is an event
but may be simpler.
-- Christian
On Fri, Nov 21, 2008 at 1:44 PM, august <[EMAIL PROTECTED]> wrote:
>
>
> hi,
>
> I'm looking to create something similar to the event model in a web
> browser's DOM.
>
> I have a C++ object that can blit stuff to screen and I'd like to tie
> in a callback from the javascript side for mouse events like so:
>
> var obj = CppObject();
> obj.onmousedown = function ( e ) { // do stuff with e };
>
>
> any ideas on how to do this? The "obj.onmousedown" will be called
> from the C++ side of things as that is where the events are polled.
>
> any tips would be much appreciated. thank you - august.
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---