EasyButton
EasyButton copied to clipboard
Multiple onPressedFor
Hi, I would like to do something like this with the same button:
button.onPressedFor(1000, showIP); button.onPressedFor(3000, restartDevice);
so execute two different callback based on the pressing duration. It doesn't work for me. Just the last function is called. Any idea?
Thank you so much, Francesco
I am trying to do the same thing, and having the same problems.
Hi @FraOre and @TylerTotally, I will take a look at this.
Basically, it is the last defined OnPressedFor that is stamped in the EasyButtonBase class's members. WIhich is to say that all the previous calls to OnPressedFor are overwritten by the last one. So in the initial message, the 3000 callback it the winning one, but if they were declared 3000 THEN 1000, only the 1000 one will be used (and triggered)
So I believe that an array (or a chained list of events) should be set in place in order to hold the different OnPressedFor callbacks. Of course, _checkPressedTime should then loop that structure until found proper callback. I'll see how to setup something decently behaving :)
This would be a useful addition to the library