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
|
import org.lwjgl.glfw.GLFW
|
||||||
|
|
||||||
object ClickGui: SnowyScreen() {
|
object ClickGui: SnowyScreen() {
|
||||||
private var GuiDragging: Boolean = false
|
|
||||||
override val components = mutableSetOf<Element>()
|
override val components = mutableSetOf<Element>()
|
||||||
|
|
||||||
val clickBoxes get() = components.filterIsInstance<ClickBox>()
|
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 {
|
override fun mouseDragged(d: Double, e: Double, i: Int, f: Double, g: Double): Boolean {
|
||||||
if (i == GLFW.GLFW_MOUSE_BUTTON_LEFT) {
|
if (i == GLFW.GLFW_MOUSE_BUTTON_LEFT) {
|
||||||
components.forEach {
|
components.forEach {
|
||||||
if (it.isWithinBounds(d, e) && !GuiDragging) {
|
if (it.isWithinBounds(d, e) && !isDragging) {
|
||||||
GuiDragging = true
|
isDragging = true
|
||||||
it.x = d.minus(f) + (d - (it.x + it.width))
|
it.x = d.minus(f) + (d - (it.x + it.width))
|
||||||
it.y = e.minus(g) + (e - (it.y + it.height))
|
it.y = e.minus(g) + (e - (it.y + it.height))
|
||||||
} else GuiDragging = false
|
} else isDragging = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.mouseDragged(d, e, i, f, g)
|
return super.mouseDragged(d, e, i, f, g)
|
||||||
|
|
Loading…
Reference in New Issue