How Do I position a popup in gwt to at mouse position. I have a huge flextable and the flextable contains button. If a button is pressed then a popup appears with some data, but the popup always appears at the top of the page. if a user is at the bottom of the table, then the popup will be out of the view and they are unable to see it?
How to I get the x and y co-ordinates of the mouse position?
The showRelativeTo method of the PopupPanel class works well in my use-case.
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.PopupPanel.PositionCallback;
public class CommentPanelPopupImage extends Image {
public CommentPanelPopupImage(final int tableId, final String referenceId, final String title) {
super("external-link-ltr-icon.png");
setTitle("Click to see comments");
final CommentPanelPopupImage commentPanelPopupImage = this;
addClickHandler(new ClickHandler() {
public void onClick(final ClickEvent event) {
final CommentPopupPanel popup = new CommentPopupPanel(tableId, referenceId, title);
popup.setPopupPositionAndShow(new PositionCallback() {
public void setPosition(int offsetWidth, int offsetHeight) {
popup.showRelativeTo(commentPanelPopupImage);
}
});
}
});
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With