Skip to content

Commit

Permalink
Added click listener for the left and right pagination arrows.
Browse files Browse the repository at this point in the history
  • Loading branch information
lanceewing committed Apr 3, 2024
1 parent 7069666 commit f2bc786
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions core/src/main/java/com/agifans/agile/ui/PaginationWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

import com.agifans.agile.HomeScreen;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Widget;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;

/**
* A widget from drawing the pagination at the bottom of the PagedScrollPane.
Expand Down Expand Up @@ -51,8 +53,19 @@ public PaginationWidget(HomeScreen homeScreen, float width) {

setSize(getPrefWidth(), getPrefHeight());

addListener(new InputListener() {
// TODO: Handle click/touch
addListener(new ClickListener(-1) {
@Override
public void clicked(InputEvent event, float x, float y) {
//System.out.println("clicked: " + x + ", y: " + y);
if (y < PAGINATION_BAR_HEIGHT) {
if (x < ICON_SIZE) {
homeScreen.keyUp(Keys.LEFT);
}
if (x > (width - ICON_SIZE)) {
homeScreen.keyUp(Keys.RIGHT);
}
}
}
});
}

Expand Down

0 comments on commit f2bc786

Please sign in to comment.