Skip to content

Commit

Permalink
Implemented proper key switching between strings
Browse files Browse the repository at this point in the history
  • Loading branch information
NickP0is0n committed Aug 25, 2021
1 parent bdb4e38 commit 5594bb7
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main/kotlin/me/nickp0is0n/easylocalize/ui/MainWindowView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
})
Expand Down

0 comments on commit 5594bb7

Please sign in to comment.