Page 1 of 1

How to detect if the interface is locked

Posted: 17 October 2020, 13:13
by salty-horse
In some situations, when a player clicks a card, I call ajaxcall() immediately.
If the player clicks the card too soon afterwards, this prompts an error from the server.

I would like to detect if the second click is made during an ajaxcall(), and disable it.
(I already disable the clickable elements in onLeavingState, but this is happening before that)

Is there a way to do that without hooking code into the ajaxcall() success and failure callbacks?
Is there a different way I should go about it?

Re: How to detect if the interface is locked

Posted: 17 October 2020, 13:19
by Tisaac
You can use this.isInterfaceLocked()

Re: How to detect if the interface is locked

Posted: 17 October 2020, 14:06
by salty-horse
Thanks! Maybe someone knowledgeable can document it in the game interface wiki page...?

Re: How to detect if the interface is locked

Posted: 17 October 2020, 15:14
by Victoria_La
You should not disable/enable click callbacks, if you really bothered about this error just do nothing in handler if (this.isInterfaceLocked()).
But I think error is better, why they click so fast?

Re: How to detect if the interface is locked

Posted: 17 October 2020, 15:30
by Victoria_La
salty-horse wrote: 17 October 2020, 14:06 Thanks! Maybe someone knowledgeable can document it in the game interface wiki page...?
I updated the wiki with the following:

this.isInterfaceLocked()

When using "lock: true" in ajax call you can use this function to check if interface is in lock state (it will be locked during server call and notification processing). This check can be used to block some other interactions which do not result in ajaxcall.