dominic
dominic

Reputation: 405

Catch GWT ClickEvent at Button

I have a button which shows a DialogBox when you click on it.

However if you click on the button it shows the DialogBox and th same time it will close and then open again.

It seems that the closeEvent of the DialogBox is thwrown before the clickEvent on the button. So if you check dialogBox.isShowing() it will open again. Because the dialog is closed when the clickEvent to show the box is thrown.

My idea was to catch the onClick event and throw it away but I don't know how to do this.

Anybody knows a way to fix this Problem?

Upvotes: 0

Views: 201

Answers (2)

Suresh Atta
Suresh Atta

Reputation: 121998

Asking about event.preventDefault() ??

you can catch the event inside the click handler of button.

Upvotes: 1

lgraham076
lgraham076

Reputation: 81

You could create a variable to hold the status of the dialog.

if(myDialogOpen==false)
{
    openDialog();
}

Or you could hold dialogbox as variable in the class you're using.

DialogBox myDialog;
if(myDialog==null)
{
    openDialog()
}

Either way you would have to reset the variable when you open or close the dialogbox. Essentially if the dialogbox is already open it does nothing.

These are a few possible ideas,maybe if you add some of the code of what you have done so far I can give you a better answer.

Upvotes: 1

Related Questions