Event handling in jsMode - registerMethod() and mouse handling.

edited December 2013 in JavaScript Mode

Can anyone suggest current good practice for handling mouse events in javascript mode?

I can't use mousePressed(), mouseDragged() etc. because I need to handle mouse events in separate classes and don't want them to require explicit coding in the mouse methods of the main sketch.

I had hoped that the new Processing 2 registerMethod() approach would be the way to go, as this has been designed to be platform neutral. But unfortunately, it does not appear to be implemented in Processing.js yet.

I guess I could add some javascript to the HTML that wraps a built Processing.js applet, but I'd much rather a solution that works directly from the Processing IDE in Javascript mode.

Any thoughts?


  • AFAIK, Processing.js v1.4.1 is still very much Processing v1.5.1! @-)
    And I remember the way to register events between v1 & v2 are completely different! #-o
    So I suggest trying to run your code using the old P1.5.1 and see how it goes there! :-\"

  • Unfortunately that's not really an option. Apart from me needing to support Processing 2.x, the old 1.5.x mouse event handling used java.awt.event classes so was also not compatible with Javascript.

Sign In or Register to comment.