G4P with P2D/P3D :: Processing bug

If you use G4P together with P2D/P3D you might have experienced problems with the controls not responding to the mouse. It has taken me ages to track down the problem but I have found it. G4P uses the cursor(…) method to changed the mouse icon when it moves over the control. Unfortunately using cursor(…) with P2D/P3D generates a fake MouseEvent.ENTER which is adversely affecting G4P.

Fortunately there is a work around by switching off the mouse over icon change action. It is demonstrated in this sketch

import g4p_controls.*;

GButton button1;

public void setup() {
  size(200, 200, P2D);
  G4P.setMouseOverEnabled(false); // use this until the bug is fixed
  button1 = new GButton(this, 10, 10, 160, 80, "Mary had a little lamb its fleece was white as snow");
}

public void handleButtonEvents(GButton button, GEvent event) {
  System.out.println(button.getText() + "   >>> ");
}

public void draw() {
  background(255, 255, 200);
} 

I have posted an issue on github.

4 Likes