Page 1 of 1

Is there any example of timer Control?

Posted: 13 May 2016 7:17
by Ferenc Nagy
Hi,
I need such an example where the timer control closes a dialog box after two minutes, and it counts down in itself or in an another integer or text control or in a progress bar: "You have left 50..40..30..20..10..5..4..3..2..1 seconds to chose other than the default answers". Possibly a button to stop the timer and the countdown and hold on the dialog waiting for the user's forever.

Posted: 13 May 2016 10:53
by Gukalov
tickAction/2 with counter:

Code: Select all

implement main   clauses     run() :-         _ = fignyaDLG::new().   end implement main   goal     main::run().   implement fignyaDLG     inherits dialog   clauses     new() :-         dialog::new(window::getActiveWindow()),         addShowListener({ :-             Timer = tickAction(1000, timerAct),             addMouseDownListener({ :- timerKill(Timer), setText("...") }) }),         show().   facts     counter : integer := 11.   predicates     timerAct : (). clauses     timerAct() :-         counter := counter - 1,         if 0 = counter then             close()         else             setText(string::format("%d (click to stop)", counter))         end if.   end implement fignyaDLG     class fignyaDLG : dialog     open core   end class fignyaDLG

Posted: 13 May 2016 12:23
by Ferenc Nagy
Thank you Gukalov,
Your example works.
It uses the tickAction/2 predicate within the showListener of the window. That is the timer control is not needed.