2020-04-28 04:29 AM
Hello,
I am trying to implement a basic screen timeout where the current screen is changed to the startup screen after a set time.
The timeout itself is straightfoward to implement using a tickcounter. However, the problem I am facing is resetting this counter whenever the screen is touched. I could possibly add a reset function to every button I have in the current screen but I also need the counter to be reset when the user touches any part of the screen and not just the interactive ones.
At first instance, I have utilized the handleClickEvent of the screen to basically detect any touch, which works in detecting all touches but unfortunately it also masks the button press events, so none of the buttons are interactive anymore.
It is possible that I use the clicklistener on all the buttons and basically handle the presses through that but this makes the code a bit complicated and this what I am trying to avoid.
I would like to know if there is a simpler way. So any input would be greatly appreacited.
Many thanks,
Samer
Solved! Go to Solution.
2020-04-28 05:28 AM
Do it like this:
/Martin
2020-04-28 05:28 AM
Do it like this:
/Martin
2020-04-28 06:43 AM
Works like a charm!!! Thank you very much.
2020-04-28 09:06 AM
Great! I forgot to mention that when you override handleClickEvent() in FrontEndApplication, you probably need to forward-propagate the event manually to make sure everything still works as normal. Like this:
void FrontEndApplication::handleClickEvent(Event &evt)
{
model.resetTimers();
Application::handleClickEvent(evt);
}
/Martin
2020-04-28 09:19 AM
Yes, that is exactly how I have done it.
But it is good to have it here so other people would have a reference.
Thanks again!
2020-04-28 09:24 AM
Oh, that's very insightful of you. Great! :)