Can't call JavaScript
GirkovArpa opened this issue · 8 comments
JavaScript cannot be called when using the Sciter.JS library. Nothing happens, except it returns Ok(undefined)
.
fn document_complete(&mut self, root: HELEMENT, _target: HELEMENT) {
let value = &Element::from(root).call_function("foo", &make_args!("bar"));
println!("{:?}", value); // Ok(undefined)
}
http://sciter.com/forums - better to ask there. Sciter.Js have some surprising decisions, so no idea what is working on that version and what isn't.
Very well then.
The workaround I'm using is, since JS can call Rust but not vice-versa, is have JS simply keep asking Rust if it needs to do anything, and act based on the response.
Not an efficient decision. What was the answer on sciter forums?
I have not asked yet 😛
I got it to work with:
let root = Element::from_window(frame.get_hwnd()).unwrap();
root.eval_script("Window.this.Test()").unwrap();
Got it working with this:
impl sciter::EventHandler for EventHandler {
fn get_subscription(&mut self) -> Option<sciter::dom::event::EVENT_GROUPS> {
Some(
sciter::dom::event::default_events()
| sciter::dom::event::EVENT_GROUPS::HANDLE_METHOD_CALL,
)
}
}
@GirkovArpa Wait, the title says "cannot call JS" and you are talking about "cannot be called from JS".
Also, default_events()
does include HANDLE_METHOD_CALL
by default:
Lines 1487 to 1489 in f59030a