I tried to capture a mouse event in my worker thread by changing helloworld.cpp to the following:
#include <stdio.h> #include <iostream> #include <emscripten.h> #include <html5.h> using namespace std; extern "C" { EM_BOOL mouse_callback(int eventType, const EmscriptenMouseEvent *e, void* userData) { cout << "mouse_callback+" << endl; return 0; } } int main() { cout << "HelloWorld" << endl; emscripten_set_click_callback(0,0,1, mouse_callback); return 0; } I then change my build commands as follows to generate a html instead: emcc helloworld.cpp --proxy-to-worker -s EXPORTED_FUNCTIONS="['_mouse_callback', '_main']" -o helloworld.html My mouse_callback was not triggered when I moved the mouse over the browser. Does anyone know if I'm doing it correctly? On Wednesday, August 26, 2015 at 2:59:13 PM UTC+8, awt wrote: > > Hi, > > I was trying to generate a javascript output for a simple hello world > program and insert it into my own html file. These are my build commands: > > emcc helloworld.cpp --proxy-to-worker -o helloworld.js > > This is my helloworld.html file: > > <html> > <header></header> > <body> > <script src="helloworld.js"></script> > </body> > </html> > > This is my cpp file: > > #include <stdio.h> > #include <iostream> > > using namespace std; > int main() { > cout << "HelloWorld" << endl; > return 0; > } > > I get the following error: > Uncaught ReferenceError: Module is not defined > > at the following line of code in helloworld.js: > > ['mousedown', 'mouseup', 'mousemove', 'DOMMouseScroll', 'mousewheel', > 'mouseout'].forEach(function(event) { > Module.canvas.addEventListener(event, function(event) { > worker.postMessage({ target: 'canvas', event: cloneObject(event) }); > event.preventDefault(); > }, true); > > Do I need to manually declare the Module object in helloworld.html? Or > should I just include helloworld.worker.js in helloworld.html directly? > -- 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 emscripten-discuss+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.