Closed GirkovArpa closed 2 years ago
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: https://github.com/sciter-sdk/rust-sciter/blob/f59030af0a00052a2759ca28667bed24a6448c2d/src/dom.rs#L1487-L1489
JavaScript cannot be called when using the Sciter.JS library. Nothing happens, except it returns
Ok(undefined)
.