Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I keep a ClickHandler from being called twice on a button in GWT?
    text
    copied!<p>Here's the setup: I have a page, we'll call it A, which contains a button, we'll call it B. When a user clicks on B, a dialog opens (C). C knows nothing about A or B once it has been created. </p> <p>Right now, if a user double-clicks on B, 2 or more Cs are created, which is not desirable. Since C knows nothing about B, I cannot disable the button because if a user presses Cancel in C, they will go back to A but B will still be disabled. I also can't save the page ID and limit C from being created that way because if a user does open C, clicks Cancel but then decides to open C again, they have to be able to do that.</p> <p>How can I stop the button from allowing more than one dialog to open, no matter how many clicks are done in succession?</p> <p><strong>EDIT</strong><br> I simplified too much in the above description, so here's a more in depth look. My <code>Toolbar</code> class has a button called <code>reference</code>. When <code>reference</code> is clicked, a function is called on an entirely separate class, <code>ItemPicker</code>, which creates and displays the <code>CreateConversation</code> dialog. So, relating back to my original scenario, B doesn't know anything about C. I realize this is convoluted, but it's not something I can change at the moment.</p> <p>Somehow, I need to stop <code>reference</code> from making a second call to <code>ItemPicker.createAndShow()</code> if it's clicked more than once and a <code>CreateConversation</code> dialog is already being opened. Also, there isn't a specific instance of <code>ItemPicker</code> in the <code>Toolbar</code> class; <code>createAndShow()</code> is a static method.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload