Steven De Groote
Steven De Groote

Reputation: 2233

Handle click outside of SmartGWT Window

I'm able to handle a click inside my window, but how can I trigger a function (outsideClick()) when the user clicks anywhere out of my Window?

My window is not modal, and it is possible for the user to select text in it (it act somewhat as a tooltip). However, I have to do some stuff when the user clicks out of the window, and I can't seem to work out how to do this.

I have already added a blurhandler on my form in the background, but of course, when the user tries to select some text in my opened window, the field blurs, and my outsideClick() function gets triggered as well (which should not happen).

EDIT - Also note that the popup Window contains a canvas with html content created as a string (please don't ask why, I know it's not very nice)

Anyone able to help me?

Upvotes: 0

Views: 1217

Answers (1)

Nicolas Rabier
Nicolas Rabier

Reputation: 36

In Smartgwt, the class com.smartgwt.client.widgets.Window has a boolean propriety called dismissOnOutsideClick. If you set it at true, a click outside the bounds of the Window will have the same effect as pressing its cancel button.

Please note that this feature works only on modal windows.

Window w = new Window();
w.setWidth(100);
w.setHeight(100);
w.setShowModalMask(false);
//
w.setIsModal(true);    
w.setDismissOnOutsideClick(true);
//
w.addItem(new Label("Test"));
w.show();

Upvotes: 2

Related Questions