Dear Vaadin users,
I experience the following problem with
AbsoluteLayout
: I would like to show the
PopupView
on layout mouse click. Here is the code for the listener:
PopupView popupViewComponent = null;
/**
* @see com.vaadin.event.LayoutEvents.LayoutClickListener#layoutClick(com.vaadin.event.LayoutEvents.LayoutClickEvent)
*/
public void layoutClick(LayoutEvents.LayoutClickEvent event) {
// Remove the previous one, if any:
if (popupViewComponent != null) {
layout.removeComponent(popupViewComponent);
}
PopupView popupViewComponent = new ...;
layout.addComponent(popupViewComponent);
ComponentPosition position = layout.getPosition(popupViewComponent);
position.setLeft(Float.valueOf(event.getRelativeX()), UNITS_PIXELS);
position.setTop(Float.valueOf(event.getRelativeY()), UNITS_PIXELS);
popupViewComponent.setPopupVisible(true);
}
What is happening: the popup is shown, but always at position (0, 0) i.e. leftmost top position of the window (even not the layout). I’ve double checked the mouse coordinates: they are not zero.
P.S. The contents of the popup depends on the mouse position.