Skip to content

Commit afb891d

Browse files
authored
Standalone: Fix key repeat
GitHub: #81
1 parent 182b126 commit afb891d

File tree

2 files changed

+11
-1
lines changed
  • standalone
    • example/src/main/kotlin/gg/essential/example
    • src/main/kotlin/gg/essential/universal/standalone

2 files changed

+11
-1
lines changed

standalone/example/src/main/kotlin/gg/essential/example/main.kt

+10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package gg.essential.example
22

33
import gg.essential.elementa.components.UIRoundedRectangle
4+
import gg.essential.elementa.components.input.UITextInput
45
import gg.essential.elementa.dsl.constrain
6+
import gg.essential.elementa.dsl.pixels
57
import gg.essential.elementa.font.DefaultFonts
68
import gg.essential.elementa.layoutdsl.*
79
import gg.essential.elementa.state.v2.State
@@ -81,6 +83,14 @@ fun LayoutScope.exampleScreen(extraFontsLoaded: State<Boolean>) {
8183
}
8284
row(Modifier.height(17f)) {}
8385
}
86+
box(Modifier.childBasedSize(padding = 1f).color(Color.GRAY)) {
87+
val textInput = UITextInput("Text Input")
88+
textInput.setMinWidth(100.pixels)
89+
textInput.setMaxWidth(100.pixels)
90+
box(Modifier.childBasedSize(padding = 2f).color(Color.DARK_GRAY)) {
91+
textInput()
92+
}.onMouseClick { textInput.grabWindowFocus() }
93+
}
8494
box(Modifier.childBasedSize(5f).color(Color.GRAY).hoverColor(Color.LIGHT_GRAY).hoverScope()) {
8595
geistText("Quit")
8696
}.onMouseClick {

standalone/src/main/kotlin/gg/essential/universal/standalone/UCWindow.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class UCWindow(val glfwWindow: GlfwWindow, val uiScope: CoroutineScope) {
7272
GLFW.glfwSetKeyCallback(glfwWindow.glfwId) { _, key, _, action, modifiers ->
7373
uiScope.launch {
7474
when (action) {
75-
GLFW.GLFW_PRESS -> {
75+
GLFW.GLFW_PRESS, GLFW.GLFW_REPEAT -> {
7676
UKeyboard.keysDown.add(key)
7777
UScreen.currentScreen?.onKeyPressed(key, 0.toChar(), modifiers.toModifiers())
7878
}

0 commit comments

Comments
 (0)