webview / webview_go

Go language bindings for the webview library.
MIT License
176 stars 27 forks source link

[bug] After launching the window, the methods ( "Navigation", "SetHtml") do not work #7

Closed GoHippo closed 9 months ago

GoHippo commented 9 months ago

I needed to change the page address or apply html code, but after launching the main window, these methods ( "Navigation", "setHtml") no longer work. Nothing happens after they are called. `

w := webview.New(false)
defer w.Destroy()

w.SetSize(800, 600, webview.HintNone)
w.Navigate("https://example.com")

go func() {
    for {
        w.Navigate("https://google.com")

        time.Sleep(5 * time.Second)
    }
}()

w.Run()

`

system_os: Windows 10 go_version: 1.19

SteffenL commented 9 months ago

You need to use Dispatch():

w.Dispatch(func() {
    w.Navigate("https://google.com")
})
SteffenL commented 9 months ago

If you have anything to add then feel free to comment. Closing for now.