pub struct Config { /* private fields */ }
Expand description
The configuration for the desktop application.
Implementations§
Source§impl Config
impl Config
Sourcepub fn with_resource_directory(self, path: impl Into<PathBuf>) -> Self
pub fn with_resource_directory(self, path: impl Into<PathBuf>) -> Self
set the directory from which assets will be searched in release mode
Sourcepub fn with_data_directory(self, path: impl Into<PathBuf>) -> Self
pub fn with_data_directory(self, path: impl Into<PathBuf>) -> Self
set the directory where data will be stored in release mode.
Note: This must be set when bundling on Windows.
Set whether or not the right-click context menu should be disabled.
Sourcepub fn with_disable_drag_drop_handler(self, disable: bool) -> Self
pub fn with_disable_drag_drop_handler(self, disable: bool) -> Self
Set whether or not the file drop handler should be disabled. On Windows the drop handler must be disabled for HTML drag and drop APIs to work.
Sourcepub fn with_prerendered(self, content: String) -> Self
pub fn with_prerendered(self, content: String) -> Self
Set the pre-rendered HTML content
Sourcepub fn with_event_loop(self, event_loop: EventLoop<UserWindowEvent>) -> Self
pub fn with_event_loop(self, event_loop: EventLoop<UserWindowEvent>) -> Self
Set the event loop to be used
Sourcepub fn with_window(self, window: WindowBuilder) -> Self
pub fn with_window(self, window: WindowBuilder) -> Self
Set the configuration for the window.
Sourcepub fn with_as_child_window(self) -> Self
pub fn with_as_child_window(self) -> Self
Set the window as child
Sourcepub fn with_close_behaviour(self, behaviour: WindowCloseBehaviour) -> Self
pub fn with_close_behaviour(self, behaviour: WindowCloseBehaviour) -> Self
Sets the behaviour of the application when the last window is closed.
Sourcepub fn with_custom_event_handler(
self,
f: impl FnMut(&Event<'_, UserWindowEvent>, &EventLoopWindowTarget<UserWindowEvent>) + 'static,
) -> Self
pub fn with_custom_event_handler( self, f: impl FnMut(&Event<'_, UserWindowEvent>, &EventLoopWindowTarget<UserWindowEvent>) + 'static, ) -> Self
Sets a custom callback to run whenever the event pool receives an event.
Sourcepub fn with_custom_protocol<F>(self, name: impl ToString, handler: F) -> Self
pub fn with_custom_protocol<F>(self, name: impl ToString, handler: F) -> Self
Set a custom protocol
Sourcepub fn with_asynchronous_custom_protocol<F>(
self,
name: impl ToString,
handler: F,
) -> Self
pub fn with_asynchronous_custom_protocol<F>( self, name: impl ToString, handler: F, ) -> Self
Set an asynchronous custom protocol
Example Usage
let cfg = Config::new()
.with_asynchronous_custom_protocol("asset", |request, responder| {
tokio::spawn(async move {
responder.respond(
HTTPResponse::builder()
.status(404)
.body(Cow::Borrowed("404 - Not Found".as_bytes()))
.unwrap()
);
});
});
note a key difference between Dioxus and Wry, the protocol name doesn’t explicitly need to be a
String
, but needs to implement ToString
.
See wry
for more details on implementation
Sourcepub fn with_custom_head(self, head: String) -> Self
pub fn with_custom_head(self, head: String) -> Self
Inject additional content into the document’s HEAD.
This is useful for loading CSS libraries, JS libraries, etc.
Sourcepub fn with_custom_index(self, index: String) -> Self
pub fn with_custom_index(self, index: String) -> Self
Use a custom index.html instead of the default Dioxus one.
Make sure your index.html is valid HTML.
Dioxus injects some loader code into the closing body tag. Your document must include a body element!
Sourcepub fn with_root_name(self, name: impl Into<String>) -> Self
pub fn with_root_name(self, name: impl Into<String>) -> Self
Set the name of the element that Dioxus will use as the root.
This is akin to calling React.render() on the element with the specified name.
Sourcepub fn with_background_color(self, color: (u8, u8, u8, u8)) -> Self
pub fn with_background_color(self, color: (u8, u8, u8, u8)) -> Self
Sets the background color of the WebView. This will be set before the HTML is rendered and can be used to prevent flashing when the page loads. Accepts a color in RGBA format
Sets the menu the window will use. This will override the default menu bar.
Note: Menu will be hidden if
with_decorations
is set to false and passed intowith_window