Skip to content

Commit

Permalink
Fixed load_html example
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorKoenders committed Nov 7, 2023
1 parent 6b1f0e8 commit 600dda8
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions examples/load_html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT

fn main() -> wry::Result<()> {
use wry::{
application::{
event::{Event, StartCause, WindowEvent},
event_loop::{ControlFlow, EventLoopBuilder},
window::{Window, WindowBuilder},
},
webview::WebViewBuilder,
};
use tao::{
event::{Event, StartCause, WindowEvent},
event_loop::{ControlFlow, EventLoopBuilder},
window::WindowBuilder,
};
use wry::WebViewBuilder;

fn main() -> wry::Result<()> {
enum UserEvent {
LoadHtml,
}
Expand All @@ -21,15 +19,16 @@ fn main() -> wry::Result<()> {

let window = WindowBuilder::new()
.with_title("Load HTML")
.build(&event_loop)?;
.build(&event_loop)
.unwrap();

let ipc_handler = move |_: &Window, req: String| {
let ipc_handler = move |req: String| {
if req == "load-html" {
let _ = proxy.send_event(UserEvent::LoadHtml);
}
};

let webview = WebViewBuilder::new(window)?
let webview = WebViewBuilder::new(&window)
.with_html(
r#"
<button onclick="window.ipc.postMessage('load-html')">Load HTML</button>
Expand Down

0 comments on commit 600dda8

Please sign in to comment.