From 05dcbee2614d7956cfa39ae3181f0d4267dd54d5 Mon Sep 17 00:00:00 2001 From: Username404 <w.iron.zombie@gmail.com> Date: Sun, 27 Jun 2021 13:24:13 +0200 Subject: [PATCH] Use isDragging instead of a private variable in ClickGui.kt --- common/src/main/kotlin/fr/username404/snowygui/ClickGui.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/common/src/main/kotlin/fr/username404/snowygui/ClickGui.kt b/common/src/main/kotlin/fr/username404/snowygui/ClickGui.kt index 10b0fad..b8d9e45 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/ClickGui.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/ClickGui.kt @@ -7,7 +7,6 @@ import fr.username404.snowygui.gui.elements.ClickBox import org.lwjgl.glfw.GLFW object ClickGui: SnowyScreen() { - private var GuiDragging: Boolean = false override val components = mutableSetOf<Element>() val clickBoxes get() = components.filterIsInstance<ClickBox>() @@ -19,11 +18,11 @@ object ClickGui: SnowyScreen() { override fun mouseDragged(d: Double, e: Double, i: Int, f: Double, g: Double): Boolean { if (i == GLFW.GLFW_MOUSE_BUTTON_LEFT) { components.forEach { - if (it.isWithinBounds(d, e) && !GuiDragging) { - GuiDragging = true + if (it.isWithinBounds(d, e) && !isDragging) { + isDragging = true it.x = d.minus(f) + (d - (it.x + it.width)) it.y = e.minus(g) + (e - (it.y + it.height)) - } else GuiDragging = false + } else isDragging = false } } return super.mouseDragged(d, e, i, f, g)