2
如何将弹出窗口定位在GWT中鼠标单击的位置。我尝试使用getX和getY来设置弹性,并将Popup设置为该位置,但这不起作用。定位弹出窗口GWT
如何将弹出窗口定位在GWT中鼠标单击的位置。我尝试使用getX和getY来设置弹性,并将Popup设置为该位置,但这不起作用。定位弹出窗口GWT
简单的例子:
final RootLayoutPanel rootLayoutPanel = RootLayoutPanel.get();
final FocusPanel focusPanel = new FocusPanel();
/* just to make the clickable area visible */
focusPanel.getElement().getStyle().setBackgroundColor("red");
rootLayoutPanel.add(focusPanel);
final PopupPanel popupPanel = new PopupPanel();
popupPanel.add(new Label("Popup"));
popupPanel.show();
focusPanel.addClickHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
final int left = event.getClientX();
final int top = event.getClientY();
popupPanel.setPopupPosition(left, top);
}
});
注:
left = event.getRelativeX(myContextElem);
等)sinkEvents(Event.ONMOUSEDOWN)
。