-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheval.rs
40 lines (39 loc) · 1.01 KB
/
eval.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use miniblink::{app, webview::*};
fn main() {
app::init("mb.dll").unwrap();
let view = WebView::default();
view.on_query(|_wv, msg, request| -> (QueryMessage, String) {
match msg {
0 => (0, format!("hello, {}", request)),
_ => (-1, "".into()),
}
});
view.on_close(|_wv| std::process::exit(0));
view.move_to_center();
view.load_html_with_base_url(
r#"
<html>
<head>
<title>Hello, world!</title>
</head>
<body>
<input id="input1"></input>
<input id="input2" disabled></input>
<button onclick="say_hello();">Hello</button>
<script>
var say_hello = function(){
var input1=document.getElementById('input1');
var input2=document.getElementById('input2');
window.mbQuery(0, input1.value, function(message, response) {
input2.value=response;
});
}
</script>
</body>
</html>
"#,
"",
);
view.show();
app::run_message_loop();
}