To let a user do scrolling, you have to use a scrollpanel with any
widget with a size bigger than the parent scrollpanel.
I use a 'personalized' ScrollPanel with touch support
(TouchScrollPanel, at the end of this mail). That panel must fit the
mobile screen. Then, inside that panel, you have to insert any widget,
with the size desired. If that widget is bigger than the scrollPanel,
then you will be able to scroll.
GWT 2.3 already let the user to do vertical and horizontal scroll with
touch and mouse events. With GWT 2.2, you will have to do horizontal
scroll manually with touch events (detect onTouchStart,onTouchMove and
onTouchEnd):
void onTouchStart(TouchStartEvent event) {
startPoint = event.getChangedTouches().get(0).getClientX();
startScroll=scrollPanel.getHorizontalScrollPosition();
}
void onTouchMove(TouchMoveEvent event) {
int change = (startPoint-
event.getChangedTouches().get(0).getClientX());
scrollPanel.setHorizontalScrollPosition(startScroll+change);
event.preventDefault();
}
void onTouchEnd(TouchEndEvent event) {
startPoint=0;
startScroll = 0;
}
public class TouchableScrollPanel extends ScrollPanel implements
HasAllTouchHandlers {
@Override
public HandlerRegistration addTouchStartHandler(TouchStartHandler
handler) {
return addDomHandler(handler, TouchStartEvent.getType());
}
@Override
public HandlerRegistration addTouchMoveHandler(TouchMoveHandler
handler) {
return addDomHandler(handler, TouchMoveEvent.getType());
}
@Override
public HandlerRegistration addTouchEndHandler(TouchEndHandler
handler) {
return addDomHandler(handler, TouchEndEvent.getType());
}
@Override
public HandlerRegistration addTouchCancelHandler(TouchCancelHandler
handler) {
return addDomHandler(handler, TouchCancelEvent.getType());