如何在PopT中的鼠标点击位置定位Popup。我尝试使用getX,并在flextable上设置getY并将Popup设置为该位置,但这不起作用。
答案 0 :(得分:2)
快速举例:
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)
。