Use isDragging instead of a private variable in ClickGui.kt
This commit is contained in:
parent
a5b1c45a86
commit
05dcbee261
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue