Not sure where the problem is (I didn't implement that API myself, not very familiar with the code) but you might take a look at tests/test_html5_mouse.c for example, which tests that API, and is known to work.
On Wed, Aug 26, 2015 at 5:41 PM, awt <knightac...@gmail.com> wrote: > Thanks for your reply Alon, are there other APIs that I can use to capture > mouse and keyboard events in Emscripten > besides emscripten_set_click_callback? Or do you think the issue lies with > my mouse_callback itself? > > On Thursday, August 27, 2015 at 6:01:35 AM UTC+8, Alon Zakai wrote: >> >> The mouse_callback doesn't seem to work without --proxy-to-worker either, >> so proxying isn't the issue either. I'm not sure offhand what is wrong >> there, but it should be easier to debug without proxying. >> >> On Wed, Aug 26, 2015 at 2:59 PM, Alon Zakai <alon...@gmail.com> wrote: >> >>> Yes, the JS running in the HTML needs a Module object, so that we can >>> find the canvas element to render to, text area to show stdout to, and so >>> forth. If you emit an html file instead of js, that will be emitted for >>> you. Otherwise, you need to create it in the HTML. >>> >>> It's definitely an error that we fail in this way, though. I fixed this >>> on incoming, we'll show a warning now, and provide some basic Module >>> functionality if one is not defined (writing to console.log for stdout, >>> etc.) >>> >>> >>> On Tue, Aug 25, 2015 at 11:59 PM, awt <knigh...@gmail.com> 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. >>>> >>> >>> >> -- > 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. > -- 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.