From 384c66e1ec2af2f72a461653bab081d327a9b0f0 Mon Sep 17 00:00:00 2001 From: Callum Bugajski <11320476+CallumBugajski@users.noreply.github.com> Date: Wed, 18 Sep 2024 19:53:45 +0100 Subject: [PATCH] Add ElementaVersion V7 for disabling input events when an error has occurred during drawing --- api/Elementa.api | 1 + src/main/kotlin/gg/essential/elementa/ElementaVersion.kt | 8 ++++++++ .../kotlin/gg/essential/elementa/components/Window.kt | 8 ++++---- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/api/Elementa.api b/api/Elementa.api index 6c4aeaa3..6b82ab59 100644 --- a/api/Elementa.api +++ b/api/Elementa.api @@ -7,6 +7,7 @@ public final class gg/essential/elementa/ElementaVersion : java/lang/Enum { public static final field V4 Lgg/essential/elementa/ElementaVersion; public static final field V5 Lgg/essential/elementa/ElementaVersion; public static final field V6 Lgg/essential/elementa/ElementaVersion; + public static final field V7 Lgg/essential/elementa/ElementaVersion; public final fun enableFor (Lkotlin/jvm/functions/Function0;)Ljava/lang/Object; public static fun valueOf (Ljava/lang/String;)Lgg/essential/elementa/ElementaVersion; public static fun values ()[Lgg/essential/elementa/ElementaVersion; diff --git a/src/main/kotlin/gg/essential/elementa/ElementaVersion.kt b/src/main/kotlin/gg/essential/elementa/ElementaVersion.kt index 3077ccef..e63c2687 100644 --- a/src/main/kotlin/gg/essential/elementa/ElementaVersion.kt +++ b/src/main/kotlin/gg/essential/elementa/ElementaVersion.kt @@ -90,8 +90,14 @@ enum class ElementaVersion { /** * [gg.essential.elementa.components.ScrollComponent] now has a minimum size for scrollbar grips. */ + @Deprecated(DEPRECATION_MESSAGE) V6, + /** + * [gg.essential.elementa.components.Window] now disables input events if an error has occurred during drawing. + */ + V7, + ; /** @@ -134,7 +140,9 @@ Be sure to read through all the changes between your current version and your ne internal val v4 = V4 @Suppress("DEPRECATION") internal val v5 = V5 + @Suppress("DEPRECATION") internal val v6 = V6 + internal val v7 = V7 @PublishedApi diff --git a/src/main/kotlin/gg/essential/elementa/components/Window.kt b/src/main/kotlin/gg/essential/elementa/components/Window.kt index 0dfc3e87..a71b8a9b 100644 --- a/src/main/kotlin/gg/essential/elementa/components/Window.kt +++ b/src/main/kotlin/gg/essential/elementa/components/Window.kt @@ -171,7 +171,7 @@ class Window @JvmOverloads constructor( } override fun mouseScroll(delta: Double) { - if (hasErrored) { + if (hasErrored && version >= ElementaVersion.v7) { return } @@ -189,7 +189,7 @@ class Window @JvmOverloads constructor( } override fun mouseClick(mouseX: Double, mouseY: Double, button: Int) { - if (hasErrored) { + if (hasErrored && version >= ElementaVersion.v7) { return } @@ -238,7 +238,7 @@ class Window @JvmOverloads constructor( } override fun mouseRelease() { - if (hasErrored) { + if (hasErrored && version >= ElementaVersion.v7) { return } @@ -250,7 +250,7 @@ class Window @JvmOverloads constructor( } override fun keyType(typedChar: Char, keyCode: Int) { - if (hasErrored) { + if (hasErrored && version >= ElementaVersion.v7) { return }