How to detect if the interface is locked

Game development with Board Game Arena Studio
Post Reply
User avatar
salty-horse
Posts: 78
Joined: 14 June 2012, 23:08

How to detect if the interface is locked

Post 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?
User avatar
Tisaac
Posts: 2743
Joined: 26 August 2014, 21:28

Re: How to detect if the interface is locked

Post by Tisaac »

You can use this.isInterfaceLocked()
User avatar
salty-horse
Posts: 78
Joined: 14 June 2012, 23:08

Re: How to detect if the interface is locked

Post by salty-horse »

Thanks! Maybe someone knowledgeable can document it in the game interface wiki page...?
User avatar
Victoria_La
Posts: 665
Joined: 28 December 2015, 20:55

Re: How to detect if the interface is locked

Post 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?
User avatar
Victoria_La
Posts: 665
Joined: 28 December 2015, 20:55

Re: How to detect if the interface is locked

Post 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.
Post Reply

Return to “Developers”