pub struct Window { /* private fields */ }
Expand description
Sciter window.
Implementations
sourceimpl Window
impl Window
sourcepub fn create(
rect: (i32, i32, i32, i32),
flags: SCITER_CREATE_WINDOW_FLAGS,
parent: Option<HWINDOW>
) -> Window
pub fn create(
rect: (i32, i32, i32, i32),
flags: SCITER_CREATE_WINDOW_FLAGS,
parent: Option<HWINDOW>
) -> Window
Create a new window with the specified position as rect(x, y, width, height)
, flags and an optional parent window.
sourcepub fn get_host(&self) -> Rc<Host>
pub fn get_host(&self) -> Rc<Host>
Obtain reference to Host
which allows you to control sciter engine and windows.
sourcepub fn sciter_handler<Callback: HostHandler + Sized>(
&mut self,
handler: Callback
)
pub fn sciter_handler<Callback: HostHandler + Sized>(
&mut self,
handler: Callback
)
Set callback for sciter engine events.
sourcepub fn event_handler<Handler: EventHandler>(&mut self, handler: Handler)
pub fn event_handler<Handler: EventHandler>(&mut self, handler: Handler)
Attach dom::EventHandler
to the Sciter window.
You can install Window EventHandler only once - it will survive all document reloads.
sourcepub fn archive_handler(&mut self, resource: &[u8]) -> Result<(), ()>
pub fn archive_handler(&mut self, resource: &[u8]) -> Result<(), ()>
Register an archive produced by packfolder
.
See documentation of the Archive
.
sourcepub fn register_behavior<Factory>(&mut self, name: &str, factory: Factory)where
Factory: Fn() -> Box<dyn EventHandler> + 'static,
pub fn register_behavior<Factory>(&mut self, name: &str, factory: Factory)where
Factory: Fn() -> Box<dyn EventHandler> + 'static,
Register a native event handler for the specified behavior name.
Behavior is a named event handler which is created for a particular DOM element. In Sciter’s sense, it is a function that is called for different UI events on the DOM element. Essentially it is an analog of the WindowProc in Windows.
In HTML, there is a behavior
CSS property that defines name of a native module
that is responsible for initialization and event handling on the element.
For example, by defining div {behavior:button}
you are asking all <div>
elements in your markup
to behave as buttons: generate BUTTON_CLICK
DOM events when clicks on that element and be focusable.
When the engine discovers element having behavior: xyz;
defined in its style,
it sends the SC_ATTACH_BEHAVIOR
host notification
with the name "xyz"
and element handle to the application.
You can consume the notification and respond to it yourself,
or the default handler walks through the list of registered behavior factories
and creates the instance of the corresponding dom::EventHandler
.
Example:
struct Button;
impl sciter::EventHandler for Button {}
let mut frame = sciter::Window::new();
frame.register_behavior("custom-button", || { Box::new(Button) });
And in HTML it can be used as:
<button style="behavior: custom-button">Rusty button</button>