pub struct Host { /* private fields */ }
Expand description
Sciter host runtime support.
Implementations§
Source§impl Host
impl Host
Sourcepub fn attach(hwnd: HWINDOW) -> Host
pub fn attach(hwnd: HWINDOW) -> Host
Attach Sciter host to an existing window.
Usually Sciter window is created by sciter::Window::create()
,
but you can attach Sciter to an existing native window.
In this case you need to mix-in
window events processing with SciterProcND
(Windows only).
Sciter engine will be initialized either on WM_CREATE
or WM_INITDIALOG
response
or by calling SciterCreateOnDirectXWindow
(again, Windows only).
Sourcepub fn attach_with<Handler: HostHandler>(
hwnd: HWINDOW,
handler: Handler,
) -> Host
pub fn attach_with<Handler: HostHandler>( hwnd: HWINDOW, handler: Handler, ) -> Host
Attach Sciter host to an existing window with the given Host
handler.
Sourcepub fn event_handler<Handler: EventHandler>(&self, handler: Handler)
pub fn event_handler<Handler: EventHandler>(&self, handler: Handler)
Attach dom::EventHandler
to the Sciter window.
Sourcepub fn register_behavior<Factory>(&self, name: &str, factory: Factory)
pub fn register_behavior<Factory>(&self, name: &str, factory: Factory)
Register a native event handler for the specified behavior name.
See the Window::register_behavior
for an example.
Sourcepub fn register_archive(&self, resource: &[u8]) -> Result<()>
pub fn register_archive(&self, resource: &[u8]) -> Result<()>
Register an archive produced by packfolder
.
See documentation of the Archive
.
Sourcepub fn enable_debug(&self, enable: bool)
pub fn enable_debug(&self, enable: bool)
Set debug mode for this window.
Sourcepub fn load_html(&self, html: &[u8], uri: Option<&str>) -> bool
pub fn load_html(&self, html: &[u8], uri: Option<&str>) -> bool
Load an HTML document from memory.
Sourcepub fn data_ready(&self, uri: &str, data: &[u8])
pub fn data_ready(&self, uri: &str, data: &[u8])
This function is used as response to HostHandler::on_data_load
request.
Sourcepub fn data_ready_async(
&self,
uri: &str,
data: &[u8],
request_id: Option<HREQUEST>,
)
pub fn data_ready_async( &self, uri: &str, data: &[u8], request_id: Option<HREQUEST>, )
Use this function outside of HostHandler::on_data_load
request.
It can be used for two purposes:
- Asynchronious resource loading in respect of
on_data_load
requests (you must userequest_id
in this case). - Refresh of an already loaded resource (for example, dynamic image updates).
Sourcepub fn eval_script(&self, script: &str) -> Result<Value, Value>
pub fn eval_script(&self, script: &str) -> Result<Value, Value>
Evaluate the given script in context of the current document.
This function returns Result<Value,Value>
with script function result value or with Sciter script error.
Sourcepub fn call_function(&self, name: &str, args: &[Value]) -> Result<Value, Value>
pub fn call_function(&self, name: &str, args: &[Value]) -> Result<Value, Value>
Call a script function defined in the global namespace.
This function returns Result<Value,Value>
with script function result value or with Sciter script error.
You can use the &make_args!(args...)
macro which helps you
to construct script arguments from Rust types.
Sourcepub fn set_home_url(&self, url: &str) -> Result<()>
pub fn set_home_url(&self, url: &str) -> Result<()>
Set home url for Sciter resources.
If you set it like set_home_url("https://sciter.com/modules/")
then
<script src="sciter:lib/root-extender.tis">
will load
root-extender.tis from
https://sciter.com/modules/lib/root-extender.tis
.
Sourcepub fn set_media_type(&self, media_type: &str) -> Result<()>
pub fn set_media_type(&self, media_type: &str) -> Result<()>
Set media type of this Sciter instance.
For example, media type can be “handheld”, “projection”, “screen”, “screen-hires”, etc.
By default, Sciter window has the "screen"
media type.
Media type name is used while loading and parsing style sheets in the engine, so you should call this function before loading document in it.
Sourcepub fn set_media_vars(&self, media: &Value) -> Result<()>
pub fn set_media_vars(&self, media: &Value) -> Result<()>
Set media variables (dictionary) for this Sciter instance.
By default Sciter window has "screen:true"
and "desktop:true"/"handheld:true"
media variables.
Media variables can be changed in runtime. This will cause styles of the document to be reset.
§Example
host.set_media_vars( &vmap! {
"screen" => true,
"handheld" => true,
}).unwrap();