sciter-sdk / rust-sciter

Rust bindings for Sciter
https://sciter.com
MIT License
804 stars 75 forks source link

Window as arguments cause error #135

Open Donald2010 opened 2 years ago

Donald2010 commented 2 years ago

in main.rs,

struct Handler;
impl Handler {
    fn process_window(&self, Window) -> () {   
    }
}
impl sciter::EventHandler for Handler {
    dispatch_script_call! {
        fn process_window(Window) ;
    }
}

in main.htm

var wnd = new Window({ 
                    url   :"file://D:\\develop\\rust\\child.htm",  
                    state : Window.WINDOW_HIDDEN, 
                    isTopmost: true,
                    frameType :  "solid", 
                })
                Window.this.xcall("process_window",wnd);
                wnd.state=Window.WINDOW_SHOWN;

when run, there is error:

 the trait bound `*mut _WINDOW: FromValue` is not satisfied
   the trait `FromValue` is not implemented for `*mut _WINDOW`

How could I pass the child window, wnd ,or it's handle to rust ?
I wan't to some properties of new window. Or alternatively , could I create the separate child window from rust code ?

pravic commented 2 years ago
dispatch_script_call! {
        fn process_window(Value) ;
    }

Try this. Basically, leave the window as a Sciter value. What do you want to do with it in general?

sciter::Window is a wrapper over a native HWND, but Window in JS is a totally different type.