Browse Source

Update README.md

pull/871/head
Igor Demin 3 years ago committed by GitHub
parent
commit
5478392f61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      tutorials/Window_API_new/README.md

13
tutorials/Window_API_new/README.md

@ -388,7 +388,9 @@ private fun onWindowRelocate(position: WindowPosition) {
import androidx.compose.material.TextField
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.input.key.Key
import androidx.compose.ui.input.key.KeyEventType
import androidx.compose.ui.input.key.key
import androidx.compose.ui.input.key.type
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.application
@ -397,12 +399,11 @@ fun main() = application {
Window(
onCloseRequest = ::exitApplication,
onPreviewKeyEvent = {
when (it.key) {
Key.Escape -> {
exitApplication()
true
}
else -> false
if (it.type == KeyEventType.KeyDown && it.key == Key.Escape) {
exitApplication()
true
} else {
false
}
}
) {

Loading…
Cancel
Save