Remove query panel when pressing escape

This commit is contained in:
DBotThePony 2023-03-08 19:59:58 +07:00
parent 33aadb2487
commit f403ce9051
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -1,5 +1,6 @@
package ru.dbotthepony.mc.otm.client.screen.panels.input package ru.dbotthepony.mc.otm.client.screen.panels.input
import com.mojang.blaze3d.platform.InputConstants
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
@ -63,4 +64,14 @@ open class QueryUserPanel<out S: Screen>(
toScreenCenter() toScreenCenter()
} }
override fun keyPressedInternal(key: Int, scancode: Int, mods: Int): Boolean {
if (key == InputConstants.KEY_ESCAPE) {
onCancel?.run()
remove()
return true
}
return super.keyPressedInternal(key, scancode, mods)
}
} }