pub trait HostHandler {
// Provided methods
fn on_data_load(&mut self, pnm: &mut SCN_LOAD_DATA) -> Option<LOAD_RESULT> { ... }
fn on_data_loaded(&mut self, pnm: &SCN_DATA_LOADED) { ... }
fn on_attach_behavior(&mut self, pnm: &mut SCN_ATTACH_BEHAVIOR) -> bool { ... }
fn on_engine_destroyed(&mut self) { ... }
fn on_graphics_critical_failure(&mut self) { ... }
fn on_invalidate(&mut self, pnm: &SCN_INVALIDATE_RECT) { ... }
fn on_debug_output(
&mut self,
subsystem: OUTPUT_SUBSYTEMS,
severity: OUTPUT_SEVERITY,
message: &str,
) { ... }
fn data_ready(
&self,
hwnd: HWINDOW,
uri: &str,
data: &[u8],
request_id: Option<HREQUEST>,
) { ... }
fn attach_behavior<Handler: EventHandler>(
&self,
pnm: &mut SCN_ATTACH_BEHAVIOR,
handler: Handler,
) { ... }
}
Expand description
Sciter notification handler for Window.sciter_handler()
.
§Resource handling and custom resource loader
HTML loaded into Sciter may contain external resources: CSS (Cascading Style Sheets),
images, fonts, cursors and scripts.
To get any of such resources Sciter will first send a on_data_load(SCN_LOAD_DATA)
notification
to your application using the callback handler registered with sciter::Window.sciter_handler()
function.
Your application can provide your own data for such resources (for example, from the resource section, database or other storage of your choice) or delegate the resource loading to the built-in HTTP client or file loader, or discard the loading at all.
Note: This handler should be registered before any
load_html()
or
load_file()
calls
in order to send notifications while loading.
Provided Methods§
Sourcefn on_data_load(&mut self, pnm: &mut SCN_LOAD_DATA) -> Option<LOAD_RESULT>
fn on_data_load(&mut self, pnm: &mut SCN_LOAD_DATA) -> Option<LOAD_RESULT>
Notifies that Sciter is about to download the referred resource.
You can load or overload data immediately by calling self.data_ready()
with parameters provided by SCN_LOAD_DATA
,
or save them (including request_id
) for later usage and answer here with LOAD_RESULT::LOAD_DELAYED
code.
Also you can discard the request (data will not be loaded at the document) or take care about this request completely by yourself (via the request API).
Sourcefn on_data_loaded(&mut self, pnm: &SCN_DATA_LOADED)
fn on_data_loaded(&mut self, pnm: &SCN_DATA_LOADED)
This notification indicates that external data (for example, image) download process completed.
Sourcefn on_attach_behavior(&mut self, pnm: &mut SCN_ATTACH_BEHAVIOR) -> bool
fn on_attach_behavior(&mut self, pnm: &mut SCN_ATTACH_BEHAVIOR) -> bool
This notification is sent on parsing the document and while processing elements
having non empty behavior:
style attribute value.
Sourcefn on_engine_destroyed(&mut self)
fn on_engine_destroyed(&mut self)
This notification is sent when instance of the engine is destroyed.
Sourcefn on_graphics_critical_failure(&mut self)
fn on_graphics_critical_failure(&mut self)
This notification is sent when the engine encounters critical rendering error: e.g. DirectX gfx driver error. Most probably bad gfx drivers.
Sourcefn on_invalidate(&mut self, pnm: &SCN_INVALIDATE_RECT)
fn on_invalidate(&mut self, pnm: &SCN_INVALIDATE_RECT)
This notification is sent when the engine needs some area to be redrawn.
Sourcefn on_debug_output(
&mut self,
subsystem: OUTPUT_SUBSYTEMS,
severity: OUTPUT_SEVERITY,
message: &str,
)
fn on_debug_output( &mut self, subsystem: OUTPUT_SUBSYTEMS, severity: OUTPUT_SEVERITY, message: &str, )
This output function will be used for reporting problems found while loading html and css documents.
Sourcefn data_ready(
&self,
hwnd: HWINDOW,
uri: &str,
data: &[u8],
request_id: Option<HREQUEST>,
)
fn data_ready( &self, hwnd: HWINDOW, uri: &str, data: &[u8], request_id: Option<HREQUEST>, )
This function is used as response to on_data_load
request.
Parameters here must be taken from SCN_LOAD_DATA
structure. You can store them for later usage,
but you must answer as LOAD_DELAYED
code and provide an request_id
here.
Sourcefn attach_behavior<Handler: EventHandler>(
&self,
pnm: &mut SCN_ATTACH_BEHAVIOR,
handler: Handler,
)
fn attach_behavior<Handler: EventHandler>( &self, pnm: &mut SCN_ATTACH_BEHAVIOR, handler: Handler, )
This function is used as a response to the on_attach_behavior
request
to attach a newly created behavior handler
to the requested element.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.