Skip to content

Commit

Permalink
Standalone: Fix key repeat
Browse files Browse the repository at this point in the history
GitHub: #81
  • Loading branch information
Johni0702 committed Aug 15, 2024
1 parent 182b126 commit afb891d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions standalone/example/src/main/kotlin/gg/essential/example/main.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package gg.essential.example

import gg.essential.elementa.components.UIRoundedRectangle
import gg.essential.elementa.components.input.UITextInput
import gg.essential.elementa.dsl.constrain
import gg.essential.elementa.dsl.pixels
import gg.essential.elementa.font.DefaultFonts
import gg.essential.elementa.layoutdsl.*
import gg.essential.elementa.state.v2.State
Expand Down Expand Up @@ -81,6 +83,14 @@ fun LayoutScope.exampleScreen(extraFontsLoaded: State<Boolean>) {
}
row(Modifier.height(17f)) {}
}
box(Modifier.childBasedSize(padding = 1f).color(Color.GRAY)) {
val textInput = UITextInput("Text Input")
textInput.setMinWidth(100.pixels)
textInput.setMaxWidth(100.pixels)
box(Modifier.childBasedSize(padding = 2f).color(Color.DARK_GRAY)) {
textInput()
}.onMouseClick { textInput.grabWindowFocus() }
}
box(Modifier.childBasedSize(5f).color(Color.GRAY).hoverColor(Color.LIGHT_GRAY).hoverScope()) {
geistText("Quit")
}.onMouseClick {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class UCWindow(val glfwWindow: GlfwWindow, val uiScope: CoroutineScope) {
GLFW.glfwSetKeyCallback(glfwWindow.glfwId) { _, key, _, action, modifiers ->
uiScope.launch {
when (action) {
GLFW.GLFW_PRESS -> {
GLFW.GLFW_PRESS, GLFW.GLFW_REPEAT -> {
UKeyboard.keysDown.add(key)
UScreen.currentScreen?.onKeyPressed(key, 0.toChar(), modifiers.toModifiers())
}
Expand Down

0 comments on commit afb891d

Please sign in to comment.