On Fri, 21 Nov 2008 11:44:47 pm august 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.
>


Local<Value>
callMethod(
    Local<Object>   object,
    const char*     methodName,
    int             argc,
    Handle<Value>   argv[]
    )
{
    Local<Value>    func   = object->Get(String::New(methodName));

    if (func->IsFunction())
    {
        Local<Function> f = Local<Function>::Cast(func);

        return f->Call(object, argc, argv);
    }
    else
    {
        return Local<Value>();
    }
}


-- 
Anthony Shipman                    Mamas don't let your babies 
[EMAIL PROTECTED]                   grow up to be outsourced.

--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to