Skip to content

Commit

Permalink
[scene2d.ui] ScrollPane, fixed scrolling via mouse wheel when there a…
Browse files Browse the repository at this point in the history
…re scrollbars in only one direction.
  • Loading branch information
NathanSweet committed Dec 27, 2020
1 parent 7933720 commit f3a7c6b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions gdx/src/com/badlogic/gdx/scenes/scene2d/ui/ScrollPane.java
Expand Up @@ -105,7 +105,7 @@ public ScrollPane (@Null Actor widget, ScrollPaneStyle style) {
addScrollListener();
}

protected void addCaptureListener() {
protected void addCaptureListener () {
addCaptureListener(new InputListener() {
private float handlePosition;

Expand Down Expand Up @@ -182,7 +182,7 @@ public boolean mouseMoved (InputEvent event, float x, float y) {
});
}

protected ActorGestureListener getFlickScrollListener() {
protected ActorGestureListener getFlickScrollListener () {
return new ActorGestureListener() {
public void pan (InputEvent event, float x, float y, float deltaX, float deltaY) {
setScrollbarsVisible(true);
Expand Down Expand Up @@ -216,11 +216,16 @@ public boolean handle (Event event) {
};
}

protected void addScrollListener() {
protected void addScrollListener () {
addListener(new InputListener() {
public boolean scrolled (InputEvent event, float x, float y, float scrollAmountX, float scrollAmountY) {
setScrollbarsVisible(true);
if (scrollY || scrollX) {
if (scrollY) {
if (!scrollX && scrollAmountY == 0) scrollAmountY = scrollAmountX;
} else {
if (scrollX && scrollAmountX == 0) scrollAmountX = scrollAmountY;
}
setScrollY(amountY + getMouseWheelY() * scrollAmountY);
setScrollX(amountX + getMouseWheelX() * scrollAmountX);
} else
Expand Down

0 comments on commit f3a7c6b

Please sign in to comment.