Button pressed twice on mobile before action is executed. Prevent this?

Button pressed twice on mobile before action is executed. Prevent this?

  

On OutSystems mobile (10.0.xxx) I'm having trouble with users being able to press a button multiple times in a very short time. In the action following the OnClick event, a record is created in the local storage. When this particular record is found, the button is hidden; but this takes a fraction of a second. 

Whenever the user presses the button twice, the OnClick client action is also executed twice. This seems logical behaviour on mobile, but I want to prevent the user from clicking the button twice by disabling the button immediately, even before the OnClick event is handled. It seems tricky to do some database checks just before saving the record, because there might be database locks or other factors. Logical place for me to do this is prevent it in the front-end. 

Any ideas? 

Hello Rob,

Have you tried the class "Button Load" from SilkUI?

I think this class should prevent double clicks on buttons. You could also do the same logic through Javascript.

Best regards,

Cristiano

Cristiano Marques wrote:

Hello Rob,

Have you tried the class "Button Load" from SilkUI?

I think this class should prevent double clicks on buttons. You could also do the same logic through Javascript.

Best regards,

Cristiano

Thanks for the suggestion Cristiano. I don't have the load class, since we use a custom theme and this is for a mobile app. 


I've been able to solve this using a custom boolean on the enabled property which is immediately set when the client action is fired. Because the property is immediately set on mobile, the UI also responds immediately. After all the updates, checks and onfetches are completed, the boolean is then switched back, and in my case the card with the button gets flipped and other controls appear. 

It's interesting to see there can be a significant difference in time before the button gets enabled again, so a property like this seems like a good practice.