Hi Claudio, sorry for the late reply here, I wonder if you were able to solve this or not. The problem here is that emscripten_set_click_callback() is being used from within an EM_ASM_INT() block, but because emscripten_set_click_callback() is a C API function, it won't be available on JS side directly. Try either calling emscripten_set_click_callback() from C code, or use the regular JS side event handling mechanisms to add an event handler in the JS land. Does that work?
Cheers, Jukka 2016-12-16 21:44 GMT+02:00 claudio daffra <[email protected]>: > > This is my attempt to emulate querySelector, in order to use it to set > more click events. > I have take a look inside* library_html.js* and i found > *emscripten_set_click_callback*:, > but something went wrong ... as can you see in error below : > > #include <emscripten.h> > #include <emscripten/html5.h> > #include <stdio.h> > > /* > EM_BOOL key_callback(int eventType, const EmscriptenKeyboardEvent *e, void > *userData) > { > printf("You pressed key %lu\n", e->which); > return 1; > } > */ > EM_BOOL click_callback(int eventType, const EmscriptenMouseEvent *e, void > *userData) > { > printf("You just clicked\n"); > return 1; > } > > // ..................................................... query selector > > char* querySelector( const char *q,const char *userData,const char * > userCapture,const char *callbackfunc ) > { > char *element ; > > element = (char*)EM_ASM_INT( > { > var q = Pointer_stringify ( $0 ) > ; > var userData = Pointer_stringify ( $1 ) ; > var useCapture = Pointer_stringify ( $2 ) ; > > var callbackfunc = Pointer_stringify ( $3 ) ; > > var ids = $(q).map(function() { return this.id; }).toArray > (); > > console.log ( "array querySelector id" ) ; > console.log ( ids ) ; > > console.log ( Module ) ; > return -1 ; > > for (i=0;i<ids.length;ids++) > { > > > > > * ??? > emscripten_set_click_callback( ids[i] , userData, userCapture, > callbackfunc ); ???* > } > > return 0 ; > },q,userData,userCapture,callbackfunc ) ; > > return element ; > } > > > > int main() > { > > querySelector ( ".x","0","1","click_callback" ) ; > > return 0; > } > > > any help ? > > > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
