Is there any example of timer Control?

Discussions related to Visual Prolog
User avatar
Ferenc Nagy
VIP Member
Posts: 289
Joined: 24 Apr 2007 12:26

Is there any example of timer Control?

Unread post by Ferenc Nagy » 13 May 2016 7:17

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.
TIA, Regards,
Frank Nagy

User avatar
Gukalov
Active Member
Posts: 27
Joined: 5 Oct 2011 15:16

Unread post by Gukalov » 13 May 2016 10:53

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

User avatar
Ferenc Nagy
VIP Member
Posts: 289
Joined: 24 Apr 2007 12:26

Unread post by Ferenc Nagy » 13 May 2016 12:23

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.
TIA, Regards,
Frank Nagy

Post Reply