Is is possible to continuous redraw? #555
-
I see that typically the screen is redrawn after an event. Is it possible to have the screen redrawn based on time if no event occurs? What I am trying to do is implement a clock and eventually add a stop watch. So I would like to have the time update regardless of what the user is doing. Perhaps this is something obvious that I have missed. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello @btraquair! It uses a thread to periodically post event/task/animation: screen_interactive.PostEvent(Event::Custom) or screen_interactive.RequestAnimationFrame(); If you don't want to add a thread, you can use the Loop loop(&screen, component);
int interation = 0;
while (!loop.HasQuitted()) {
loop.RunOnce();
std::this_thread::sleep_for(std::chrono::milliseconds(10));
interaction++;
if (iteration % 10 == 0)
screen.RequestAnimationFrame();
}
Does it work? |
Beta Was this translation helpful? Give feedback.
Hello @btraquair!
There is an example on the wiki: https://github.com/ArthurSonzogni/FTXUI/wiki/Screen#force-redraw
It uses a thread to periodically post event/task/animation:
or
If you don't want to add a thread, you can use the
Loop
to interleave ftxui loop with it:Does it work?