Best way to implement Screen timeout?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-28 4: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.
- Labels:
-
TouchGFX
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-28 5:28 AM
Do it like this:
- Keep track of your timers (timeout, etc) in your model.
- Once the timers run out, carry out whatever action. Maybe they're recurring.
- In FrontEndApplication.hpp/cpp override the handleClickEvent() method and make a call to your Model to reset the timers that need to be, like a timeout timer.
/Martin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-28 5:28 AM
Do it like this:
- Keep track of your timers (timeout, etc) in your model.
- Once the timers run out, carry out whatever action. Maybe they're recurring.
- In FrontEndApplication.hpp/cpp override the handleClickEvent() method and make a call to your Model to reset the timers that need to be, like a timeout timer.
/Martin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-28 6:43 AM
Works like a charm!!! Thank you very much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-28 9: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-28 9: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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-28 9:24 AM
Oh, that's very insightful of you. Great! :)
