From 5594bb78d2d6b5c488e026eab8c03ca71511eec0 Mon Sep 17 00:00:00 2001 From: Mykola Chaikovskyi Date: Wed, 25 Aug 2021 19:55:03 +0300 Subject: [PATCH] Implemented proper key switching between strings --- .../nickp0is0n/easylocalize/ui/MainWindowView.kt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/me/nickp0is0n/easylocalize/ui/MainWindowView.kt b/src/main/kotlin/me/nickp0is0n/easylocalize/ui/MainWindowView.kt index 67dc71b..a321159 100644 --- a/src/main/kotlin/me/nickp0is0n/easylocalize/ui/MainWindowView.kt +++ b/src/main/kotlin/me/nickp0is0n/easylocalize/ui/MainWindowView.kt @@ -200,16 +200,28 @@ class MainWindowView { modifier = Modifier .padding(top = 10.dp) .size(width = 450.dp, height = 160.dp) - .onPreviewKeyEvent { + .onKeyEvent { when { (it.isAltPressed && it.key == Key.DirectionDown) -> { if (selectedID != -1 && selectedID + 1 < stringList.size) { selectedID++ fieldValuesModel.stringFieldValue.value = stringList[selectedID].text fieldValuesModel.commentFieldValue.value = stringList[selectedID].comment + this@MainWindowView.stringList[selectedID] = this@MainWindowView.stringList[selectedID] //selection color workaround } true } + + (it.isAltPressed && it.key == Key.DirectionUp) -> { + if (selectedID != -1 && selectedID - 1 > 0) { + selectedID-- + fieldValuesModel.stringFieldValue.value = stringList[selectedID].text + fieldValuesModel.commentFieldValue.value = stringList[selectedID].comment + this@MainWindowView.stringList[selectedID] = this@MainWindowView.stringList[selectedID] //selection color workaround + } + true + } + else -> false } })