diff --git a/common/src/main/kotlin/fr/username404/snowygui/ClickGui.kt b/common/src/main/kotlin/fr/username404/snowygui/ClickGui.kt index 4d32b77..10b0fad 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/ClickGui.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/ClickGui.kt @@ -4,6 +4,7 @@ import fr.username404.snowygui.gui.ColoredElement import fr.username404.snowygui.gui.Element import fr.username404.snowygui.gui.SnowyScreen import fr.username404.snowygui.gui.elements.ClickBox +import org.lwjgl.glfw.GLFW object ClickGui: SnowyScreen() { private var GuiDragging: Boolean = false @@ -16,7 +17,7 @@ object ClickGui: SnowyScreen() { override fun mouseReleased(d: Double, e: Double, i: Int): Boolean { buttonsContext { this.mouseReleased(d, e, i) }; return false } override fun mouseScrolled(d: Double, e: Double, f: Double): Boolean { boxContext { scroll(d, e, f) }; return false } override fun mouseDragged(d: Double, e: Double, i: Int, f: Double, g: Double): Boolean { - if (i == 0) { + if (i == GLFW.GLFW_MOUSE_BUTTON_LEFT) { components.forEach { if (it.isWithinBounds(d, e) && !GuiDragging) { GuiDragging = true diff --git a/common/src/main/kotlin/fr/username404/snowygui/gui/Element.kt b/common/src/main/kotlin/fr/username404/snowygui/gui/Element.kt index d9c7a90..8d6ebeb 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/gui/Element.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/Element.kt @@ -30,7 +30,7 @@ abstract class Element( ): Renderable, GuiEventListener { open var width = originalWidth; open var height = originalHeight open var x = xOrigin; open var y = yOrigin - internal fun isWithinBounds(coordinateX: Double, coordinateY: Double, offsetWidth: Double = 0.0, offsetHeight: Double = 0.0): Boolean = + fun isWithinBounds(coordinateX: Double, coordinateY: Double, offsetWidth: Double = 0.0, offsetHeight: Double = 0.0): Boolean = (coordinateX in x..(x + width + offsetWidth)) && (coordinateY in y..(y + height + offsetHeight)) companion object { private var caughtError: Boolean = false diff --git a/common/src/main/kotlin/fr/username404/snowygui/gui/SnowyScreen.kt b/common/src/main/kotlin/fr/username404/snowygui/gui/SnowyScreen.kt index cb5d849..2a62695 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/gui/SnowyScreen.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/SnowyScreen.kt @@ -5,7 +5,7 @@ import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.TranslatableComponent abstract class SnowyScreen(translatableString: String = "screen.snowy.gui", private val willPauseScreen: Boolean = false): Screen(TranslatableComponent(translatableString)) { - abstract val components: MutableSet + abstract val components: MutableCollection override fun render(poseStack: PoseStack?, i: Int, j: Int, f: Float) { if (poseStack != null) { components.forEach {