How to see mouseReleased () event outside the canvas using processing.js

I have an object that I want to drag around the screen with the mouse in the Processing section. I set acquiredin trueon the mouse down the object and up falseon the mouse up, this way:

void mousePressed() {
  if (overThing()) {
    acquired = true;
  }
}

void mouseReleased() {
  acquired = false;
}

Then I query acquiredin my update()and drag the object if it is true.

void update() {
  \\ other stuff...
  if (acquired) {
    \\ drag thing code ...
  }
}

Everything works fine in processing. mouseReleased()gets a call whether the mouse is free inside or outside the active window.

, Chrome, process.js(v1.4.8), mouseReleased() , ( , - ). , ( ) , - .

mousePressed update(), true.

, , , process.js?

+4
2

, , .

, , , :

  • acquired = false mouseOut(), @Kevin.

  • , mouseEntered(), , ( , , mouseEntered()). , , , acquired = false.

:

void mouseEntered() {
  if (mouse button is pressed) {
    acquired = false;
  }
}

: , @Susan, , process.js, mousePressed false, . , , , , - .

, , , , javascript ( ):

  • mouseUp() <body>, .
  • mouseUp() , Processing. (, mouseUp(), , , ID )
  • , mouseUp , . (,!) .
  • , (x, y) , , . , ( , ), : " (x, y) - ".

Edit2: , ! JavaScript , mouseReleased . Processing, . jQuery ( , jQuery), , "processingCanvas":

$(':not(processingCanvas)').mouseup(function(){
  Processing.getInstanceById('processingCanvas').mouseReleased();
});

, ( JavaScript script > ) , ​​ jQuery.

Processing JavaScript , . , , mouseReleased(), , , , .

+2

mouseOut() , :

void mouseOut() {
  acquired = false;
}

.

+1

All Articles