Unbelievable that there is no nice way to specify where the popup should appear.
// This is a hack to have the popup shown above the text field.
private static void addPositionAdjustHandlers(DateBox dateBox) {
dateBox.getTextBox().addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
adjustPosition(dateBox);
}
});
dateBox.getTextBox().addFocusHandler(new FocusHandler() {
@Override
public void onFocus(FocusEvent event) {
adjustPosition(dateBox);
}
});
dateBox.getTextBox().addKeyDownHandler(new KeyDownHandler() {
@Override
public void onKeyDown(KeyDownEvent event) {
adjustPosition(dateBox);
}
});
}
private static void adjustPosition(DateBox dateBox) {
int top = - (dateBox.getDatePicker().getElement().getAbsoluteBottom() -
dateBox.getDatePicker().getElement().getAbsoluteTop());
dateBox.getDatePicker().getElement().setAttribute("style", "visibility: visible; overflow: visible; position: absolute; left: 0px; top: "+ top +"px;");
}