Viewport allowHorizontalScrolling


#1

Another viewport “problem”. I have used viewport.setScrollBarsShown(true, false, false, false); to prevent the horizontal scrollbar from showing and disable the horizontal scroll functionality overall. But I can still scroll horizontally using drag.


#2

You need to disable scroll by drag separately using setScrollOnDragEnabled(false).


#3

But I want to use scroll by drag. Just only in vertical direction and not horizontally.


#4

Ah, gotcha. Misunderstood. Won’t that happen automatically if the component bounds in that dimension match the bounds of the viewport?


#5

Well, yes.
In my case it’s just the vertical scrollbar that hides some content which causes horizontal scrolling. I can reduce the width of the viewedComponent but like in my other thread (Viewport, viewedComponent and position offset) this seems like an unnecessary hack.

Also for me this would include some other annoying changes. Since I have a centered component inside the viewport it would look a little off if I reduced the width. So I would have to define different offsets. It’s just easier disabling horizontal scroll.

Apart from that users would expect an argument called allowHorizontalScrollingWithoutScrollbar to disable scrolling when set to false.