PDA

View Full Version : scrollEvent not triggered



neha.chowdary
24 Nov 2011, 1:55 AM
Hi i am quite new to using gwt ext and having a tough time adding a scrolllistner to a layout container.
what i want to do is get the scroll positions on the scrollevent and use them for further calculations.
But i am not even able to get it triggered.
Here is the dummy code:

public class Workflow extends LayoutContainer implements Entrypoint {
.................
.........
.......
public void onRender(........
.........
setLayout(new FitLayout())
this.setScrollMode(Scroll.Auto);
this.addScrollListener(new ScrollListener () { @Override

public void widgetScrolled(ComponentEvent ce){
Window.alert("Scrolled");

}
});
}...

ideally this should give an alert box when i scroll ... That does not happen!!

Ersmarker
3 Jan 2012, 2:56 AM
See example:



ContentPanel c1 = new ContentPanel();
c1.setHeading("Panel 1");
c1.setSize(200, 200);
c1.setScrollMode(Scroll.AUTO);
c1.addScrollListener(new ScrollListener() {
public void widgetScrolled(ComponentEvent ce) {
Window.alert("Scrolled");
}
});
ContentPanel c2 = new ContentPanel();
c2.setHeading("Panel 2");
c2.setSize(300, 300);
c1.add(c2);
RootPanel.get().add(c1);

sven
3 Jan 2012, 2:58 AM
In the original post you are using a fitlayout. A FitLayout will never show scrollbars and so also will never fire the scrollevent.