Struct rsciter::WindowHandle

source ·
pub struct WindowHandle { /* private fields */ }
Expand description

A handle to a Sciter window object.

Implementations§

source§

impl WindowHandle

source

pub fn is_valid(&self) -> bool

source

pub fn collapse(&self) -> Result<()>

source

pub fn show(&self, kind: Visibility) -> Result<()>

Examples found in repository?
examples/debug_output.rs (line 29)
20
21
22
23
24
25
26
27
28
29
30
31
32
fn try_main() -> Result<i32> {
    app::init()?;

    let _v = setup_debug_output(|sub, sev, text| {
        eprintln!("Sub: {:?}, Level: {:?}, {text}", sub, sev);
    })?;

    let window = Window::builder().with_html(HTML).build_main()?;

    window.show(Visibility::Normal)?;

    app::run()
}
More examples
Hide additional examples
examples/custom_host.rs (line 20)
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
fn try_main() -> Result<i32> {
    app::init()?;

    let window = Window::builder().with_host(Host).build_main()?;

    window.load_file("./the/path/might/not/exist.html")?;

    // we intercept file loading in the custom host, so no scripts to run
    // show the window manually
    window.show(Visibility::Normal)?;

    let exit_code = app::run()?;

    app::shutdown()?;

    Ok(exit_code)
}
examples/archive.rs (line 29)
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
fn try_main() -> Result<i32> {
    app::init()?;

    let window = Window::builder()
        .with_archive_static(DATA)
        .with_file("this://app/main.html")
        .build_main()?;

    let window2 = Window::builder()
        .with_archive_static(DATA)
        .with_archive_uri("self://".to_string())
        .with_file("self://main.html")
        .build_secondary()?;

    window2.eval("Window.this.caption = 'Secondary'")?;

    window.show(Visibility::Normal)?;
    window2.show(Visibility::Normal)?;

    app::run()
}
examples/win_delegate_closure.rs (line 31)
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
fn try_main() -> Result<i32> {
    app::init()?;

    let window = Window::builder()
        .with_window_delegate(|_w: WindowHandle, _msg, _wp: WPARAM, _lp| {
            #[cfg(target_os = "windows")]
            {
                const VK_ESCAPE: WPARAM = WPARAM(0x1B);
                use windows::Win32::UI::WindowsAndMessaging::WM_KEYDOWN;

                if WM_KEYDOWN == _msg && _wp == VK_ESCAPE {
                    let _ = _w.collapse();
                }
            }

            (false, Default::default())
        })
        .with_html(include_bytes!("app.html"))
        .build_main()?;

    window.show(Visibility::Normal)?;

    let exit_code = app::run()?;

    app::shutdown()?;

    Ok(exit_code)
}
examples/custom_host_notification.rs (line 34)
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
41
fn try_main() -> Result<i32> {
    app::init()?;

    let window = Window::builder()
        .with_host(Host)
        .with_file("./the/path/might/not/exist.html")
        .with_window_delegate(|_w: WindowHandle, _msg, _wp: WPARAM, _lp| {
            #[cfg(target_os = "windows")]
            {
                use windows::Win32::UI::WindowsAndMessaging::WM_KEYDOWN;
                const VK_SPACE: WPARAM = WPARAM(0x20);

                if WM_KEYDOWN == _msg && _wp == VK_SPACE {
                    let _ = _w.notify_host(1, 2, 20);
                }
            }

            (false, Default::default())
        })
        .build_main()?;

    // we intercept file loading in the custom host, so no scripts to run
    // show the window manually
    window.show(Visibility::Normal)?;

    let exit_code = app::run()?;

    app::shutdown()?;

    Ok(exit_code)
}
source

pub fn hide(&self) -> Result<()>

source

pub fn request_close(&self) -> Result<()>

Close the window, scripts can reject the closure

source

pub fn close(&self) -> Result<()>

Close the window, scripts cannot reject the closure

source

pub fn activate(&self) -> Result<()>

source

pub fn bring_to_front(&self) -> Result<()>

source

pub fn load_file(&self, path: impl AsRef<str>) -> Result<bool>

Loads HTML file.

Returns true if the text was parsed and loaded successfully, ‘false’ otherwise.

Examples found in repository?
examples/custom_host.rs (line 16)
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
fn try_main() -> Result<i32> {
    app::init()?;

    let window = Window::builder().with_host(Host).build_main()?;

    window.load_file("./the/path/might/not/exist.html")?;

    // we intercept file loading in the custom host, so no scripts to run
    // show the window manually
    window.show(Visibility::Normal)?;

    let exit_code = app::run()?;

    app::shutdown()?;

    Ok(exit_code)
}
source

pub fn load_html(&self, html: &[u8], base_url: Option<&str>) -> Result<bool>

Loads an HTML document from memory.

Returns true if the document was parsed and loaded successfully, ‘false’ otherwise.

Examples found in repository?
examples/win_delegate.rs (line 27)
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
41
fn try_main() -> Result<i32> {
    // pass custom args to the Sciter Engine
    app::init_from_iter(["arg1", "arg2"].into_iter())?;

    let ux_ok = set_option(RuntimeOption::UxTheming(false))?;
    let gfx_ok = set_option(RuntimeOption::GfxLayer(GfxLayer::GFX_LAYER_AUTO))?;
    let rt_ok = set_option(RuntimeOption::ScriptFeatures(ScriptFeatures::ALLOW_ALL))?;

    dbg!(ux_ok, gfx_ok, rt_ok);

    let window = Window::builder()
        .with_window_delegate(WinDelegate::new())
        .build_main()?;

    window.load_html(include_bytes!("app.html"), None)?;

    // app.html does this like Window.this.state = Window.WINDOW_SHOWN;
    // window.show(Visibility::Normal)?;

    let exit_code = app::run()?;

    window.with_window_delegate::<WinDelegate>(|d| {
        println!("It was {} different messages", d.messages.len());
    });

    app::shutdown()?;

    Ok(exit_code)
}
source

pub fn notify_host( &self, wparam: UINT_PTR, lparam: UINT_PTR, timeoutms: UINT ) -> Result<UINT_PTR>

Posts host notifiacation. The host will get it in [HostNotifications::on_posted_notification]

source

pub fn eval(&self, script: &str) -> Result<Value>

Examples found in repository?
examples/archive.rs (line 27)
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
fn try_main() -> Result<i32> {
    app::init()?;

    let window = Window::builder()
        .with_archive_static(DATA)
        .with_file("this://app/main.html")
        .build_main()?;

    let window2 = Window::builder()
        .with_archive_static(DATA)
        .with_archive_uri("self://".to_string())
        .with_file("self://main.html")
        .build_secondary()?;

    window2.eval("Window.this.caption = 'Secondary'")?;

    window.show(Visibility::Normal)?;
    window2.show(Visibility::Normal)?;

    app::run()
}
source

pub fn call(&self, name: &str, args: &[Value]) -> Result<Value>

Trait Implementations§

source§

impl Clone for WindowHandle

source§

fn clone(&self) -> WindowHandle

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for WindowHandle

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<WindowHandle> for HWND

source§

fn from(value: WindowHandle) -> Self

Converts to this type from the input type.
source§

impl From<isize> for WindowHandle

source§

fn from(hwnd: HWND) -> Self

Converts to this type from the input type.
source§

impl PartialEq for WindowHandle

source§

fn eq(&self, other: &WindowHandle) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for WindowHandle

source§

impl Eq for WindowHandle

source§

impl StructuralPartialEq for WindowHandle

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AsAny for T
where T: 'static,

source§

fn as_any(&self) -> &(dyn Any + 'static)

source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.