Thursday, October 30, 2014

Re: datebox popup position

I don't know if your popup is a PopupPanel or a DialogBox. Here are my observations anyway...

https://groups.google.com/forum/#!search/web$20toolkit$20virvilis$20dialogbox/google-web-toolkit/tZ79yCvgNuU/HeXX9eAGeJ4J

    Vassilis


On Thu, Oct 30, 2014 at 2:27 PM, Jeppe Hansen <jeppewelling@gmail.com> wrote:
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.



--
Vassilis Virvilis

--
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