Fixed that enterPressed() has been called on ACTION_DOWN and ACTION_UP

This commit is contained in:
dankito 2020-05-15 15:18:29 +02:00
parent cee92e4d2d
commit 306669c23a
1 changed files with 2 additions and 2 deletions

View File

@ -5,8 +5,8 @@ import android.widget.EditText
fun EditText.addEnterPressedListener(enterPressed: () -> Boolean) { fun EditText.addEnterPressedListener(enterPressed: () -> Boolean) {
this.setOnKeyListener { _, keyCode, _ -> this.setOnKeyListener { _, keyCode, event ->
if (keyCode == KeyEvent.KEYCODE_ENTER) { if (keyCode == KeyEvent.KEYCODE_ENTER && event.action == KeyEvent.ACTION_UP) {
return@setOnKeyListener enterPressed() return@setOnKeyListener enterPressed()
} }