GWT dispose modal dialog by clicking outside of it - gwt

I have a HSV color selector on a dialog and I would like to provide user several ways to dispose the dialog. I have normal buttons and such but I would also like to make it disappear when user clicks outside of it.
Is there a way to do this in GWT?

You can enable PopupPanel auto hide. When enabled, the popup will be automatically hidden when the user clicks outside of it.

Related

Mouse hover on disabled button

I have a disabled button. On mouse hover of this disabled button, I need to display a popup using GWT.
I tried to wrap it inside a panel and coded mouse hover for the panel. But it's not working instantly all the time.
IMO you should try to avoid this situation. For example, if you just want to show a small tooltip you can use a different title for enabled and disabled state explaining the disabled cause.
If you still want to react to an over event on disable button you can use something like this.
SimplePanel p = new SimplePanel();
Button b = new Button("hover me to toggle disable"); p.add(b);
p.addDomHandler(ev -> button.setEnabled(!b.isEnabled()), MouseOverEvent.getType());
RootPanel.get().add(p);
Although as you already have noticed, the browser does not fire over events on disabled inputs. So if you move the mouse without passing through the panel and goes directly to the button you will not receive the event. You can fix this applying this style.
button.gwt-Button[disabled] {
pointer-events: none;
}
But probably this might have some downsides or might not work in all browsers.

Implementing "onclickout" with GWT

I need a way of capturing onclick event when a user clicks out of a FocusPanel(in the form of a dialog box). I need to warn the user to save their work before clicking outside thus losing the panel. I know how to do it in JavaScript but it I am stuck with GWT. Any assistance will be appreciated.
Every click event provides coordinates of a click. Check that these coordinates are outside of your popup panel.
Alternatively, make your PopupPanel modal, so that users can exit it only by clicking on UI elements that you provide, for example, submit and cancel/close buttons.

How to prevent GWT dialogbox from closing when clicking outside it

I plan to add a menu that pop ups when a user performs a certain action. This menu will include some fields that the user will fill out and then hit "Submit" which will close the dialog box and update the client based on information inputed.
However, I want the user to be able to close the dialog window by hitting cancel or submit, and not by clicking on the screen outside of the dialog box.
How can i do this? Or maybe I should just use a PopupPanel?
It's as easy as setting the auto-hide behavior to false, either at construction time or later.

How can I make Dialog Box to hide when user clicks anywhere outside Dialog Box?

How can I make Dialog Box to hide when user clicks anywhere outside Dialog Box?
It is a GWT application where a view is extending Dialog Box. I have a Close button in Dialog Box which OnClicked hides the Dialog Box. However, as per requirement, if user clicks anywhere outside the Dialog Box, it should hide.
Any help would be greatly appreciated.
Thanks
Use the constructor DialogBox(boolean autoHide) or the setter setAutoHideEnabled(boolean autoHide) in order to automatically hide the box when the user clicks outside of it.
You can also auto-hide on history token changes, using the setAutoHideOnHistoryEventsEnabled(boolean enabled) setter.

GWT-Google web Toolkit-DialogBox

I have doubt regarding GWT .In Gwt if i click one button than it shows one dialog box at th same time the form outside the dialog box disabled.What component can be used for this task?
Thanks in advance
So, you want to open a popup dialog box, and at the same time disable the rest of the page until the user closes the dialog box?
If so, you can simply use gwt's DialogBox.
Use the constructor with the autohide flag set to false, and the box will not close until the user responds, thus disabling the rest of the page. If you want to make this even more clear, use the glass effect:
yourBox.setGlassEnabled(true);
You can also use the PopupPanel directly and build your own custom dialog box.
Now, if I got it wrong and you want to disable the form so it remains disabled after the popup, just disable it in the onClick handler of the button that opens the box.