jchv / go-webview2

WebView2 bindings for pure Go, without CGo, based on the webview/webview bindings.
Other
263 stars 64 forks source link

Eval in Asynchronous thread not work #54

Closed kityun closed 2 years ago

kityun commented 2 years ago

go func(){

...

callback(func(){ w.Eval(" alert('Hello from webview!'); ") ) ..

}

jchv commented 2 years ago

At least for now, Eval only works on the main thread. Using Dispatch should help. You'll have to do:

w.Dispatch(func() {
    w.Eval(" alert('Hello from webview!'); ")
})