We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi!
I'm trying to use g4p controls and now I'm proving toggle image button. The problem is that I want to show one message when the button is "on" (all the time), and I can't, it shows the message only when it changes its state and then the message disappear even if the button is still "on". This is the code that I'm using:
import g4p_controls.*;
GImageToggleButton tag_OnOff;
public void setup() {
size(480, 220, JAVA2D);
G4P.setGlobalColorScheme(GCScheme.ORANGE_SCHEME);
G4P.setCursor(ARROW);
if (frame != null)
frame.setTitle("Sketch Window");
// Create image toggle buttons
tag_OnOff = new GImageToggleButton(this, 10, 90, "o_of.png", 2, 1);
}
public void handleToggleButtonEvents(GImageToggleButton button, GEvent event) {
fill(0);
if(tag_OnOff.getState()==1)
{
text("On",10,10);
}
}
public void draw() {
background(180);
}
Can you help me please??
Answers
Use a flag changed in
handleTooggleButtonEvents()
and draw indraw()
like (pseudo)
global
in draw...
in handleToggleButtonEvents
should work :)
Thanks a lot!!
:)