From 4a79ad8a259bdedae4e393096d2b017d2153cf3d Mon Sep 17 00:00:00 2001 From: yugecin Date: Sun, 11 Dec 2016 02:26:31 +0100 Subject: [PATCH] only click option when mouse was not dragged --- src/yugecin/opsudance/ui/OptionsOverlay.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/yugecin/opsudance/ui/OptionsOverlay.java b/src/yugecin/opsudance/ui/OptionsOverlay.java index a6d7c329..35fe7c3a 100644 --- a/src/yugecin/opsudance/ui/OptionsOverlay.java +++ b/src/yugecin/opsudance/ui/OptionsOverlay.java @@ -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; }