Hi all, I'm using `EditText` view with `AndroidVie...
# compose
p
Hi all, I'm using
EditText
view with
AndroidView
composable, when I press back button with
EditText
in active state,
KeyInputModifier
is crashing with
"KeyEvent can't be processed because this key input node is not active."
Is there any information on what i'm doing wrong and how to fix this? After a briefly looking into compose source code I was not able to find any handle to prevent this crash, so I'm just suppressing the crash on activity level inside of
dispatchKeyEvent
method, is there a better workaround for the issue? (compose 1.0.0-alpha07)
d
Hi! Could you please share how you suppress the crash on activity level? I’ve been having the same issue and haven’t found a solution yet either. Same thing happens when we use a
WebView
inside an
AndroidView
p
Sure, please see below:
Copy code
override fun dispatchKeyEvent(event: KeyEvent?): Boolean {
    return try {
        super.dispatchKeyEvent(event)
    } catch (e: IllegalStateException) {
        if (event?.keyCode == KeyEvent.KEYCODE_BACK) {
            onBackPressedDispatcher.onBackPressed()
            true
        } else {
            throw e
        }
    }
}
at the first look this was enough to workaround my case, however, I haven't tested if it covers all the cases yet
❤️ 1
d
Thanks. Will give this a try. Appreciate the help!