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() val clickBoxes get() = components.filterIsInstance() @@ -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)