We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Here is my code:
void controlEvent(ControlEvent theEvent) {
if (millis()>270) {
if (theEvent.isGroup()) {
label = theEvent.getGroup().getCaptionLabel().getText();
if (FirstLoad) {
b2();
FirstLoad = false;
}
}
}
}
I use if()
here because it looks like this code runs when i just start my programm. Using this condition (millis()>270)
i solved this problem, but i think it's not a good solution.
Comments
What exactly is the problem? Do you want to have an alternative for the millis() trick?
Yes, for some things, like setting values, events are sent when you create the controller. To solve this you can setBroadcast(false), do stuff, setBroadcast(true). Then you won't need your current workaround.
Note that this is why it's always better to post a small working example of the problem, since your current code example misses the relevant code. Hopefully with these new insights you will be able to solve it.
Sorry guys, I was busy, yes i wanted to have an alternative, and thanks for the answer, but i didn't get it (because I don't actually know anything about Object-oriented programming). My code is quite big and I don't want to cut it down in order to find a problem. I just can describe it: there are some text fields, some buttons and a dropdownlist. When I click on an item of dropdownlist first time this code runs (b2() correspond to the button 2)
Becuase I use this condition:
I found out that without millis() trick, the first line runs (as though button is pushed just in the beginning), and others don't. Also, i started using fonts
f = createFont("Arial",16,true);
and i had to increase delay time to 1200ms (program loads longer with fonts).
I think i'm gonna let it as it is, so thank you for answer anyway.