Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standalone: Fix key repeat #81

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -76,6 +78,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