File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
examples/reference/mouseButton/mouseButton0 Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 1+ # Click within the image and press the left and right mouse buttons to change the
2+ # value of the rectangle
3+ draw <- function() {
4+ rect(25, 25, 50, 50)
5+ }
6+
7+ mousePressed <- function() {
8+ if (mouseButton == LEFT) {
9+ fill(0)
10+ } else if (mouseButton == RIGHT) {
11+ fill(255)
12+ } else {
13+ fill(126)
14+ }
15+ }
Original file line number Diff line number Diff line change 2626import processing .core .PApplet ;
2727import processing .core .PConstants ;
2828import processing .core .PSurface ;
29+ import processing .event .MouseEvent ;
2930import processing .javafx .PSurfaceFX ;
3031import processing .opengl .PSurfaceJOGL ;
3132import rprocessing .applet .BuiltinApplet ;
@@ -381,6 +382,12 @@ protected void wrapProcessingVariables() {
381382 // this.renjinEngine.put("keyPressed", keyPressed);
382383 }
383384
385+ @ Override
386+ protected void handleMouseEvent (MouseEvent event ) {
387+ super .handleMouseEvent (event );
388+ wrapMouseVariables ();
389+ }
390+
384391 @ Override
385392 public void mouseClicked () {
386393 wrapMouseVariables ();
@@ -436,7 +443,7 @@ private void wrapMouseVariables() {
436443 this .renjinEngine .put ("mouseY" , mouseY );
437444 this .renjinEngine .put ("pmouseX" , pmouseX );
438445 this .renjinEngine .put ("pmouseY" , pmouseY );
439- // this.renjinEngine.put("mouseButton", mouseButton);
446+ this .renjinEngine .put ("mouseButton" , mouseButton );
440447 }
441448
442449 private void applyFunction (String name ) {
You can’t perform that action at this time.
0 commit comments