fjenett / javascript-mode-processing

Former ProcessingJS mode (Processing 1.5) that became JavaScript mode (Processing 2.0 beta) that has now been moved out of the Processing IDE.
57 stars 13 forks source link

touch support throwing an error in chrome #32

Closed falquaddoomi closed 9 years ago

falquaddoomi commented 9 years ago

I'm attempting to run a processing.js sketch on a mobile device, but every time the user initiates a mouse event the following exception is thrown:

Uncaught ReferenceError: eventHandlers is not defined

The error occurs at the following location in processing.js: https://github.com/fjenett/javascript-mode-processing/blob/master/resources/template/processing.js#L7575

I would have thought that 'eventHandlers' would be included in the scope where the callback to attachEventHandlers() is being defined, but apparently not. I've been able to replicate this issue using the mobile device emulator in Chrome for Windows v43.0.2357.124 m.

For completeness, I've included a basic sketch that demonstrates the problem:

void setup() {
  size(300, 300); 
}

PVector m = new PVector(), displace = new PVector();
boolean pressing = false;
void mousePressed() {
  m.set(mouseX, mouseY);
  pressing = true;
}

void mouseReleased() {
  pressing = false;
}

void draw() {
  background(0);

  if (pressing) {
    displace = PVector.sub(m, new PVector(mouseX, mouseY));
    float rad = displace.mag()*2.0;
    fill(255);
    ellipse(m.x, m.y, rad, rad);
  }
}
fjenett commented 9 years ago

Hey, this seems to be not a problem of JavaScript mode but of Processing.js itself. Please check with the latest plain version of Processing.js and if the problem is still there then report to their issues queue.