feat: disable drop handler (#3680)
This commit is contained in:
1 parent
8b9e246044
commit
18feb0b38d
2 files changed
+14
-2
No files matched your search
@@ -63,6 +63,7 @@ pub struct Config {
|
||||
pub(crate) background_color: Option<(u8, u8, u8, u8)>,
|
||||
pub(crate) last_window_close_behavior: WindowCloseBehaviour,
|
||||
pub(crate) custom_event_handler: Option<CustomEventHandler>,
|
||||
pub(crate) disable_file_drop_handler: bool,
|
||||
}
|
||||
|
||||
impl LaunchConfig for Config {}
|
||||
@@ -108,6 +109,7 @@ impl Config {
|
||||
background_color: None,
|
||||
last_window_close_behavior: WindowCloseBehaviour::LastWindowExitsApp,
|
||||
custom_event_handler: None,
|
||||
disable_file_drop_handler: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,6 +133,13 @@ impl Config {
|
||||
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.
|
||||
pub fn with_disable_drag_drop_handler(mut self, disable: bool) -> Self {
|
||||
self.disable_file_drop_handler = disable;
|
||||
self
|
||||
}
|
||||
|
||||
/// Set the pre-rendered HTML content
|
||||
pub fn with_prerendered(mut self, content: String) -> Self {
|
||||
self.pre_rendered = Some(content);
|
||||
|
||||
@@ -359,8 +359,11 @@ impl WebviewInstance {
|
||||
}
|
||||
}) // prevent all navigations
|
||||
.with_asynchronous_custom_protocol(String::from("dioxus"), request_handler)
|
||||
.with_web_context(&mut web_context)
|
||||
.with_drag_drop_handler(file_drop_handler);
|
||||
.with_web_context(&mut web_context);
|
||||
|
||||
if !cfg.disable_file_drop_handler {
|
||||
webview = webview.with_drag_drop_handler(file_drop_handler);
|
||||
}
|
||||
|
||||
if let Some(color) = cfg.background_color {
|
||||
webview = webview.with_background_color(color);
|
||||
|
||||
Reference in new issue
Block a user