Thursday, October 30, 2014

Re: datebox popup position

Unbelievable that there is no nice way to specify where the popup should appear. 
Any way, I made a simple work around that I would like to share with you:


// 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;");
}



/ Jeppe

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment