I've inserted the G4P code into my original example and made some tweaks to it.
Then I've realized it is the G4P library which changes the
cursor()'s symbol back
to its own config every time mouse moves!
So, if we modify #79 from
GP4.setCursor(ARROW); to
GP4.setCursor(WAIT);
we'd notice that the latter becomes the new default cursor for the whole sketch!
Except when mouse is hovering over GP4's own buttons. Sprite becomes
cursor(HAND) then.
That also interferes for setting
cursor() to another symbol for other parts of the sketch.
Here's the example I'm currently testing:
Main.pde:
/**
* Flicker-Free Cursor Toggle (v1.1)
* by GoToLoop (2013/Jul)
*
* http://forum.processing.org/topic
* /why-is-cursor-blinking-changes-from-arrow-to-hand
*/
import g4p_controls.*;
final CloudRect cr = new CloudRect();
boolean isHand, wasHovering;
void setup() {
size(300, 300);
//noLoop();
fill(#0000FF);
createGUI();
}
void draw() {
background(0);
cr.display();
//cursor(MOVE);
}
void mouseMoved() {
toggleCursor();
redraw();
}
void toggleCursor() {
final boolean isHovering = cr.isInside(mouseX, mouseY);
frame.setTitle("Hovering: " + isHovering);
if ( wasHovering != (wasHovering = isHovering) )
if ( isHand = !isHand ) cursor(HAND);
else cursor(ARROW);
}
class CloudRect {
short x = 80, y = 50, w = 80, h = 50;
short xw, yh;
CloudRect() {
xw = (short) (x + w);
yh = (short) (y + h);
}
CloudRect(int xx, int yy, int ww, int hh) {
x = (short) xx;
y = (short) yy;
w = (short) ww;
h = (short) hh;
xw = (short) (x + w);
yh = (short) (y + h);
}
void display() {
rect(x, y, w, h);
}
boolean isInside(int xx, int yy) {
return xx > x & xx < xw & yy > y & yy < yh;
}
}
GP4.pde:
void button1_click1(GButton source, GEvent event) { //_CODE_:button1:879951:
println("button1 - GButton event occured " + millis() % 10000000);
} //_CODE_:button1:879951:
void createGUI() {
G4P.messagesEnabled(false);
G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME);
G4P.setCursor(WAIT);
if (frame != null) frame.setTitle("Sketch Window");
button1 = new GButton(this, 196, 238, 56, 30);
button1.setText("Face Text");
button1.addEventHandler(this, "button1_click1");
}
GButton button1;