View Full Version : Does GXT provide a way to prevent double-click on buttons

18 Jun 2009, 9:07 AM
Using a selection listener although I set the Enabled to false on a button in the begining until the action is performed, the button still gets clicks. I assume its a subtle issue as you don't know the click frequency on the OS.

SelectionListener<ButtonEvent> l = new SelectionListener<ButtonEvent>(){

public void componentSelected(ButtonEvent ce) {
Button btn = ce.getButton();

............ DO SOMETHING ...........



18 Jun 2009, 9:09 AM
You mean the button still looks clicked down? You need to extend button and remove that effect if you wont want it.

18 Jun 2009, 9:17 AM
No. I mean to disable the button as soon as it gets the first click and if the user has double-clicked it, it doesn't perform the set action twice.

I have a Panel whose content can be switched between two modes. Administration and Normal and I have a button which when clickeded will switch the Panel's mode. Now although I do btn.setEnabled(false) inside the selection listener, if I double-click the button the panel gets switched from current state to the other and back :) meaning the button has fired the listener twice.

18 Jun 2009, 9:20 AM
I guess if you click the button the second time it already got enabled again. Setup a brakepoint to confirm this.

You can enable the button in a deferredcommand. But i dont see a real point in this.

18 Jun 2009, 9:26 AM
Hmm.... I agree the button does get disabled and then re-enabled. The problem is the action takes about a second to switch the panel and I assumed the button should stay disabled between that period of time. But somehow double-clicking it performs the actions twice and because the action does take that second you can visually see the panel changing from one mode to the other and back :) anyway I will look into it and see what I can do with it. thanks ...

18 Jun 2009, 9:30 AM
Than you need to enable it again in a deferredcommand.

19 Jun 2009, 12:38 AM
Thank you sven... deferred command has solved the problem ...

16 Mar 2010, 8:33 AM
this might help... a plugin to disable double clicks on buttons. It should be easily adaptable to GWT no?