web-view icon indicating copy to clipboard operation
web-view copied to clipboard

The Edge backend doesn't dispatch events when the window is being dragged around

Open radekvit opened this issue 3 years ago • 0 comments

When I drag the window around, my callbacks issued through the Handle don't get called. This does not happen with the IE backend (without the "edge" feature).

From my very short debugging, the PostThreadMessage call inside webview-sys still returns TRUE even when this happens.

Cargo.toml

[dependencies]
web-view = { version = "0.7", features = ["edge"] }

main.rs

use std::time::Duration;
use web_view::*;

fn main() {
    let html = r#"
    <html>
    <body>
    <input type="button"
           id="mybutton"
           onClick="external.invoke('button_click')"
           value="Hello, World!" />
    <script>
        function change_text(text) {
            document.getElementById('mybutton').value = text;
        }
    </script>
    </body>
    </html>"#;
    builder()
        .content(Content::Html(html))
        .user_data(())
        .invoke_handler(|webview, arg| match arg {
            "button_click" => {
                {
                    let webview = webview.handle();
                    std::thread::spawn(move || {
                        std::thread::sleep(Duration::from_secs(2));
                        webview.dispatch(|webview| 
                        // if you are dragging the window around, this doesn't get invoked
                            webview.eval("change_text('Goodbye, world!')"))
                    });
                }
                Ok(())
            }
            _ => unimplemented!(),
        })
        .run()
        .unwrap();
}

Affected versions:\

  • 0.7.2
  • master
  • (possibly others)

radekvit avatar Feb 21 '21 13:02 radekvit