0

I have a GWT ScrollPanel with a horizontal scrollbar, i.e.

overflow-y: scroll;

How can I bind a MouseWheel event on the scroll bar to perform a horizontal scrolling when the mouse wheel is moved?

Michael
  • 32,527
  • 49
  • 210
  • 370

1 Answers1

1

See this example of how to listen to a mouse wheel event: http://examples.roughian.com/index.htm#Listeners~MouseWheelListener

Instead of a label extend a ScrollPanel

Instead of setText call setHorizontalScrollPosition(int position)

public void onMouseWheel(Widget sender, MouseWheelVelocity velocity)
{
    DOM.eventPreventDefault(DOM.eventGetCurrentEvent()); //prevent vertical scroll
    int positionDelta = velocity.getDeltaY() * 30;
    int newPosition = getHorizontalScrollPosition() - positionDelta;
    setHorizontalScrollPosition(newPosition);   
}

Also see How to do a horizontal scroll on mouse wheel scroll?

Community
  • 1
  • 1
bdrx
  • 924
  • 13
  • 31