only click option when mouse was not dragged

This commit is contained in:
yugecin 2016-12-11 02:26:31 +01:00
parent 0a54d63877
commit 4a79ad8a25

View File

@ -57,6 +57,8 @@ public class OptionsOverlay {
private int scrollOffset;
private final int maxScrollOffset;
private int mousePressY;
public OptionsOverlay(Parent parent, OptionTab[] tabs, int defaultSelectedTabIndex, GameContainer container) {
this.parent = parent;
this.container = container;
@ -229,12 +231,22 @@ public class OptionsOverlay {
}
public void mousePressed(int button, int x, int y) {
mousePressY = y;
selectedOption = hoverOption;
if (UI.getBackButton().contains(x, y)) {
parent.onLeave();
return;
}
}
public void mouseReleased(int button, int x, int y) {
selectedOption = null;
// check if clicked, not dragged
if (Math.abs(y - mousePressY) >= 5) {
return;
}
if (hoverOption != null && hoverOption.getType() == OptionType.BOOLEAN) {
hoverOption.click(container);
@ -257,10 +269,6 @@ public class OptionsOverlay {
}
}
public void mouseReleased(int button, int x, int y) {
selectedOption = null;
}
public void mouseDragged(int oldx, int oldy, int newx, int newy) {
scrollOffset += oldy - newy;
}