https://kotlinlang.org logo
k

Kyant

10/24/2020, 7:28 AM
How to handle WebView back press event?
Copy code
WebComponent(
    url = url.value,
    webContext = webContext,
    modifier = Modifier.keyInputFilter {
        if (it.key == Key.Back) {
            if (webContext.canGoBack()) {
                webContext.goBack()
                true
            } else false
        } else false
    },
)
But I got exceptions
Copy code
Exception dispatching finished signal.
Exception in MessageQueue callback: handleReceiveCallback
java.lang.IllegalStateException: KeyEvent can't be processed because this key input node is not active.
g

Grigorii Yurkov

10/24/2020, 11:21 AM
I handle back press event by overriding
Activity.onBackPressed
and then pass this event to my
ViewModel
, like JetNews does
k

Kyant

10/24/2020, 11:30 AM
Didn't work. I have had this problem since 1.0.0-alpha01 or maybe later.
g

Grigorii Yurkov

10/24/2020, 12:11 PM
@Kyant Sorry, what I need to import to use
WebComponent
, I want to try it
a

Adam Powell

10/24/2020, 3:15 PM
the exception here looks like a bug in compose ui, please file it with a repro if you are able
👍 1
36 Views