PDA

View Full Version : Inconsistant behaviour using popup.show with a position



MikeHat
28 Aug 2010, 3:15 AM
Hi, I have been having some problems with the popup show method.

Using the following code for example:


package com.mikehat.popupproblem.client;

import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Popup;
import com.extjs.gxt.ui.client.widget.Viewport;
import com.extjs.gxt.ui.client.widget.button.ToggleButton;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;

/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class PopupProblem implements EntryPoint {

public void onModuleLoad() {
Viewport viewport = new Viewport();

final ToggleButton btnClick = new ToggleButton("Button");


ContentPanel panel = new ContentPanel();
panel.setButtonAlign(HorizontalAlignment.LEFT);
viewport.add(panel);

final Popup popup = new Popup();
popup.setSize(100, 20);
popup.setBorders(true);
popup.setLayout(new FitLayout());
popup.add(new TextField<String>());
popup.setConstrainViewport(true);

panel.addButton(btnClick);

btnClick.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
if (btnClick.isPressed()) {
popup.show(btnClick.getElement(), "bl-tl");
} else {
popup.hide();
}
}
});
RootPanel.get().add(viewport);
}
}



I would expect the following:
- When I select the toggle button the Popup would display with the bottom-left of the Popup aligned with the top-left of the Button.
- When I untoggle the button again I expect the Popup to be hidden.
- When I toggle the button on again I expect the Popup to be shown again aligned with the bottom-left of the Popup aligned with the top-left of the Button.

However this is not the case.

When I run the application the first time I toggle the button the popup is displayed in the expected location.

http://i35.tinypic.com/a04r6.png

When I toggle the button off the popup is hidden again as expected.

However whenever I subsequently toggle the button on the popup is displayed however the bottom-left is no longer aligned with the top-left of the button as expected.

http://i35.tinypic.com/2ug10le.png

I cannot see anything wrong so assumed it may be a bug.

Using GXT 2.1.1 and GWT 2.0.4. Behaviour is the same on Chrome/IE/Firefox on PC and Safari/Chrome/Firefox on Mac

Doc type in the host file is <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

Thanks

Mike

sven
28 Aug 2010, 4:36 AM
I run the code in FF and IE against 2.2 RC1 and it works as expected. The popup hides automatically on a click, so you dont need the hide logic.

If you dont want to autohide the popup you need to add
popup.setAutoHide(false);

MikeHat
28 Aug 2010, 5:38 AM
Thanks again Sven,

I changed from GXT 2.1.1 to GXT 2.2 RC1 and this was no longer a problem. Can I conclude this is a known bug in 2.1.1 then?

Thanks

Mike

sven
28 Aug 2010, 6:23 AM
Yes, it got probably fixed in GXT 2.1.2:
Fixed layout issue of Popup if hiding and showing it again

MikeHat
28 Aug 2010, 6:38 AM
Thanks

harinanda08
15 May 2012, 11:20 PM
i think it is again repeated in gxt 3.0