MouseEvent for tracking in all the window
in
Programming Questions
•
1 year ago
Hi!
I try to track the mouse click and scroll in the desktop, over the processing's sketch.
I just found yet how to follow the mouse mouvements :
-
import java.awt.*;PGraphics pg;
int mX, mY;
void setup() {size(int(screenWidth/3), int(screenHeight/3));pg = createGraphics(screenWidth, screenHeight, P2D);pg.beginDraw();background(0);pg.beginDraw();}void setMouseXY(){
Point mouse;mouse = MouseInfo.getPointerInfo().getLocation();mX = mouse.x;//winloc.x;mY = mouse.y;//winloc.y;}
void draw() {
setMouseXY();
pg.beginDraw();pg.noStroke();pg.fill(random(230),240,400,90);
pg.ellipse(mX,mY,12,12);if(mouseP){pg.fill(0,255,0);pg.ellipse(mX,mY,12,12);}
pg.endDraw();
image(pg, 0, 0, int(screenWidth/3), int(screenHeight/3));//println( "mX is " + mX + " and mY is " + mY );}
/*boolean mouseP=false;void mousePressed(){println("yopyop");mouseP=true;}void mouseReleased(){mouseP=false;}*/
You can try, it works!
I was looking in the java's mouseEvent but I find my limits, how do deal with it?
Thank you for your help!
2