I have expected some useful examples. LOL. But as usual, SV example in the documentation is just about nothing…
DELAY seems to be for holding down a Button. You’ll have to test if it affects extra clicks. You need IMM also.
An idea I replied to Mark… At end of process store Last Run Date and Time. Do not allow to run again for 2 seconds
IF KeyCode()=MouseLeft2 THEN CYCLE. ! Double click sends 2nd event
IF TODAY()=LastRunDate |
AND INRANGE (CLOCK()-LastRunTime,0,200) THEN CYCLE.
Do Process
LastRunDate=TODAY()
LastRunTime=CLOCK()
Will not prevent near 23:59.
Edit: I don’t think Date is really needed. There would just be a 2 second window of time it would not run in the future.
Edit: Rejecting a double click ( IF KeyCode()=MouseLeft2 THEN CYCLE.
) will stop most of this but not all, so I would keep the above time check.
Thank you, it works.
Thank you all ! ! ! !
Some quick testing of
Window WINDOW('Scratch Clarion Hub'),AT(,,400,200),CENTER,GRAY,IMM,SYSTEM,STATUS,FONT('Segoe UI',9),RESIZE
BUTTON('Button1'),AT(55,180),USE(?Button1)
BUTTON('Button2'),AT(106,180),USE(?Button2)
BUTTON('Delay 200'),AT(206,180),USE(?DelayBtn),DELAY(200),IMM
END
CASE ACCEPTED()
OF ?Button1 ; DB('?Button1 clicked Key=' & KeyCode() &' '& CLOCK() )
OF ?Button2 ; DB('?Button2 clicked Key=' & KeyCode() &' '& CLOCK() )
OF ?DelayBtn ; DB('?DelayBtn clicked Key=' & KeyCode() &' '& CLOCK() )
END
Fast clicking often (almost always) shows an Event Accepted with KeyCode=MouseLeft (1) followed by a 2nd Accepted with KeyCode=MouseLeft2 (5). Not quite so fast clicking I would sometimes see 2 Mouse Left without the Left2.
Suggest add IF KeyCode()=MouseLeft2 THEN CYCLE.
would prevent most all of this problem.
The button with DELAY(200) did not prevent clicking on it again for 2 seconds. Its feature is when you click and hold it delayed the 2nd event 2 seconds, which is what the help says. Its part of an IMM button made to hold, e.g. maybe to scroll. If I click and hold after 2 seconds more events come fast. That can be controls with REPEAT(time).
Debug below. The first 2 clicks were fast but did not have Left2. The button with DELAY(200) can be clicked
https://clarion.help/doku.php?id=delay_set_repeat_button_delay_.htm
https://clarion.help/doku.php?id=repeat_set_repeat_button_rate_.htm&s[]=prop&s[]=delay
Did you ever try ALRT(MouseLeft2) on the window def for that button?. Maybe that could solve the issue without adding code?
I thought of that also, I just confirmed ALRT with my test which is no surprise. I didn’t like the ALRT(MouseLeft2) sort of hidden on the window when reusing the code. I also think the 2 second check is still needed to prevent fast clicking that sends 2 quick Mouse Left’s
Luckily, there’s also PROP:Alrt
Some quick testing of
Window WINDOW('Scratch Clarion Hub'),AT(,,400,200),CENTER,GRAY,IMM,SYSTEM,STATUS,FONT('Segoe UI',9),RESIZE
BUTTON('Button1'),AT(55,180),USE(?Button1)
BUTTON('Button2'),AT(106,180),USE(?Button2)
BUTTON('Delay 200'),AT(206,180),USE(?DelayBtn),DELAY(200),IMM
END
CASE ACCEPTED()
OF ?Button1 ; DB('?Button1 clicked Key=' & KeyCode() )
OF ?Button2 ; DB('?Button2 clicked Key=' & KeyCode() )
OF ?DelayBtn ; DB('?DelayBtn clicked Key=' & KeyCode() )
END
Seeing that fast clicking does show an Event Accepted with MouseLeft (1) followed by MouseLeft2 (5). Not quite so fast I would sometimes see 2 Mouse Left without the Left2. Conclusion IF KeyCode()=MouseLeft2 THEN CYCLE.
should prevent most.
The button with DELAY(200) did not prevent clicking on it again for 2 seconds, it just delayed when holding down which is what the help says.
Another approach is to store a time of last execution (evtl. time of finishing) and to ignore subsequent triggers within a given time period.
Regards,
Andrzej
That was the solution in post 22. If it was within 2 seconds it does CYCLE to not run processes