0

I'm using JBCefBrowser for build my application (IntelliJ plugin). I need to handle button or link click in Java code (not JavaScript). Could someone give an advice how to do this?

Thank you!

1
  • There is no such events. Look for the navigation events in the client handler, it is the closest to what you want.
    – 3CxEZiVlQ
    Commented Dec 21, 2022 at 1:58

1 Answer 1

0
val javaScriptEngineProxy: JBCefJSQuery = JBCefJSQuery.create(browser as JBCefBrowserBase)

javaScriptEngineProxy.addHandler { result ->
    println(result)

    null
}

val injectedJavaScript = """
    window.goToLine = function() {                
        var filePath = document.getElementById("go-to-filepath").value
        var lineNumber = document.getElementById("go-to-line-number").value
        var goToPath = filePath + ":" + lineNumber
        ${javaScriptEngineProxy.inject("goToPath")}
    }
            
    """.trimIndent()

browser.cefBrowser.executeJavaScript(injectedJavaScript, browser.cefBrowser.url, 0)
1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Dec 23, 2022 at 18:21

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.