Struct rsciter::WindowHandle
source · pub struct WindowHandle { /* private fields */ }Expand description
A handle to a Sciter window object.
Implementations§
source§impl WindowHandle
impl WindowHandle
pub fn is_valid(&self) -> bool
pub fn collapse(&self) -> Result<()>
sourcepub fn show(&self, kind: Visibility) -> Result<()>
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
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)
}pub fn hide(&self) -> Result<()>
sourcepub fn request_close(&self) -> Result<()>
pub fn request_close(&self) -> Result<()>
Close the window, scripts can reject the closure
pub fn activate(&self) -> Result<()>
pub fn bring_to_front(&self) -> Result<()>
sourcepub fn load_file(&self, path: impl AsRef<str>) -> Result<bool>
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)
}sourcepub fn load_html(&self, html: &[u8], base_url: Option<&str>) -> Result<bool>
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)
}sourcepub fn notify_host(
&self,
wparam: UINT_PTR,
lparam: UINT_PTR,
timeoutms: UINT
) -> Result<UINT_PTR>
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]
sourcepub fn eval(&self, script: &str) -> Result<Value>
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()
}pub fn call(&self, name: &str, args: &[Value]) -> Result<Value>
Trait Implementations§
source§impl Clone for WindowHandle
impl Clone for WindowHandle
source§fn clone(&self) -> WindowHandle
fn clone(&self) -> WindowHandle
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for WindowHandle
impl Debug for WindowHandle
source§impl From<WindowHandle> for HWND
impl From<WindowHandle> for HWND
source§fn from(value: WindowHandle) -> Self
fn from(value: WindowHandle) -> Self
Converts to this type from the input type.
source§impl From<isize> for WindowHandle
impl From<isize> for WindowHandle
source§impl PartialEq for WindowHandle
impl PartialEq for WindowHandle
source§fn eq(&self, other: &WindowHandle) -> bool
fn eq(&self, other: &WindowHandle) -> bool
This method tests for
self and other values to be equal, and is used
by ==.impl Copy for WindowHandle
impl Eq for WindowHandle
impl StructuralPartialEq for WindowHandle
Auto Trait Implementations§
impl Freeze for WindowHandle
impl RefUnwindSafe for WindowHandle
impl Send for WindowHandle
impl Sync for WindowHandle
impl Unpin for WindowHandle
impl UnwindSafe for WindowHandle
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more