Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
nmaves
Level 7

Best way to prevent double clicks

I have a grid of titles inside of a panelset.  When you select a title it will append a panel to display that titles detail information.  If you double click the "ok" button on that grid it will append two detail panels.

What is the best way to prevent this?
0 Kudos
2 Replies
joetesta
Level 10

Re: Best way to prevent double clicks

as soon as the first click is received set a flag m.inProcess = true or something.  In your init sub, set m.inProcess = false.  In your onKeyEvent check if m.inProcess then return true so the click is ignored.  When your thing finishes adding or later goes away you need to set m.inProcess back to false so you start listening for clicks on that screen / component again.
aspiring
0 Kudos
tim_beynart
Level 7

Re: Best way to prevent double clicks

what is your keypress code? the firmware fires both "press" and "release" events for a single button click. for example:

' press is true for the down phase, false for the release phase . 
function onKeyEvent(key, press) as Boolean
if press
...do stuff...
end if
0 Kudos