Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple onPressedFor #60

Open
FraOre opened this issue Oct 1, 2021 · 4 comments
Open

Multiple onPressedFor #60

FraOre opened this issue Oct 1, 2021 · 4 comments
Assignees

Comments

@FraOre
Copy link

FraOre commented Oct 1, 2021

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

@TylerTotally
Copy link

I am trying to do the same thing, and having the same problems.

@evert-arias evert-arias self-assigned this Mar 12, 2022
@evert-arias
Copy link
Owner

Hi @FraOre and @TylerTotally, I will take a look at this.

@JFClaeys
Copy link

JFClaeys commented Mar 31, 2022

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 :)

@fastbike
Copy link

This would be a useful addition to the library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants