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.
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.
How can I stop the button from allowing more than one dialog to open, no matter how many clicks are done in succession?
EDIT
I simplified too much in the above description, so here’s a more in depth look. My Toolbar class has a button called reference. When reference is clicked, a function is called on an entirely separate class, ItemPicker, which creates and displays the CreateConversation 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.
Somehow, I need to stop reference from making a second call to ItemPicker.createAndShow() if it’s clicked more than once and a CreateConversation dialog is already being opened. Also, there isn’t a specific instance of ItemPicker in the Toolbar class; createAndShow() is a static method.
C doesn’t know B, but B knows C: keep a handle on it and call
show(). If C is already displayed, it will be a no-op, if has been closed (or not yet opened), it will show up.