pub struct Settings(/* private fields */);Expand description
The configurable settings of a WebView, such as whether JavaScript, the
dev tools, or the default context menus are enabled. Obtain it with
WebView::settings.
Each property is a getter / set_* pair; the setters take effect on the next
navigation.
Implementations§
Source§impl Settings
impl Settings
Sourcepub fn is_script_enabled(&self) -> bool
pub fn is_script_enabled(&self) -> bool
Whether running JavaScript is enabled.
Sourcepub fn set_script_enabled(&self, value: bool) -> Result<()>
pub fn set_script_enabled(&self, value: bool) -> Result<()>
Whether running JavaScript is enabled.
Sourcepub fn is_web_message_enabled(&self) -> bool
pub fn is_web_message_enabled(&self) -> bool
Whether communicating with the host via postMessage is enabled.
Sourcepub fn set_web_message_enabled(&self, value: bool) -> Result<()>
pub fn set_web_message_enabled(&self, value: bool) -> Result<()>
Whether communicating with the host via postMessage is enabled.
Sourcepub fn are_default_script_dialogs_enabled(&self) -> bool
pub fn are_default_script_dialogs_enabled(&self) -> bool
Whether the default JavaScript dialogs (alert, confirm, prompt,
beforeunload) are shown.
Sourcepub fn set_default_script_dialogs_enabled(&self, value: bool) -> Result<()>
pub fn set_default_script_dialogs_enabled(&self, value: bool) -> Result<()>
Whether the default JavaScript dialogs (alert, confirm, prompt,
beforeunload) are shown.
Sourcepub fn is_status_bar_enabled(&self) -> bool
pub fn is_status_bar_enabled(&self) -> bool
Whether the status bar is displayed.
Sourcepub fn set_status_bar_enabled(&self, value: bool) -> Result<()>
pub fn set_status_bar_enabled(&self, value: bool) -> Result<()>
Whether the status bar is displayed.
Sourcepub fn are_dev_tools_enabled(&self) -> bool
pub fn are_dev_tools_enabled(&self) -> bool
Whether the browser dev tools are available.
Sourcepub fn set_dev_tools_enabled(&self, value: bool) -> Result<()>
pub fn set_dev_tools_enabled(&self, value: bool) -> Result<()>
Whether the browser dev tools are available.
Whether the default right-click context menus are shown.
Whether the default right-click context menus are shown.
Sourcepub fn are_host_objects_allowed(&self) -> bool
pub fn are_host_objects_allowed(&self) -> bool
Whether host objects added via the WebView2 host-object APIs are accessible from the page.
Sourcepub fn set_host_objects_allowed(&self, value: bool) -> Result<()>
pub fn set_host_objects_allowed(&self, value: bool) -> Result<()>
Whether host objects added via the WebView2 host-object APIs are accessible from the page.
Sourcepub fn is_zoom_control_enabled(&self) -> bool
pub fn is_zoom_control_enabled(&self) -> bool
Whether zoom control (for example Ctrl++/-) is enabled.
Sourcepub fn set_zoom_control_enabled(&self, value: bool) -> Result<()>
pub fn set_zoom_control_enabled(&self, value: bool) -> Result<()>
Whether zoom control (for example Ctrl++/-) is enabled.
Sourcepub fn is_built_in_error_page_enabled(&self) -> bool
pub fn is_built_in_error_page_enabled(&self) -> bool
Whether the built-in error page is shown for navigation and rendering failures.
Sourcepub fn set_built_in_error_page_enabled(&self, value: bool) -> Result<()>
pub fn set_built_in_error_page_enabled(&self, value: bool) -> Result<()>
Whether the built-in error page is shown for navigation and rendering failures.
Sourcepub fn user_agent(&self) -> Result<String>
pub fn user_agent(&self) -> Result<String>
Returns the user-agent string sent with requests and reported to script.
Sourcepub fn set_user_agent(&self, user_agent: &str) -> Result<()>
pub fn set_user_agent(&self, user_agent: &str) -> Result<()>
Overrides the user-agent string sent with requests and reported to script.
Sourcepub fn are_browser_accelerator_keys_enabled(&self) -> Result<bool>
pub fn are_browser_accelerator_keys_enabled(&self) -> Result<bool>
Whether the browser’s built-in accelerator keys (such as Ctrl+F or
F5) are enabled. Disable to handle these keys yourself via
Controller::on_accelerator_key_pressed.
Sourcepub fn set_browser_accelerator_keys_enabled(&self, value: bool) -> Result<()>
pub fn set_browser_accelerator_keys_enabled(&self, value: bool) -> Result<()>
Whether the browser’s built-in accelerator keys (such as Ctrl+F or
F5) are enabled. Disable to handle these keys yourself via
Controller::on_accelerator_key_pressed.
Sourcepub fn is_general_autofill_enabled(&self) -> Result<bool>
pub fn is_general_autofill_enabled(&self) -> Result<bool>
Whether general form autofill (names, addresses, and similar) is enabled.
Sourcepub fn set_general_autofill_enabled(&self, value: bool) -> Result<()>
pub fn set_general_autofill_enabled(&self, value: bool) -> Result<()>
Whether general form autofill (names, addresses, and similar) is enabled.
Sourcepub fn is_password_autosave_enabled(&self) -> Result<bool>
pub fn is_password_autosave_enabled(&self) -> Result<bool>
Whether saving and autofilling passwords is enabled.
Sourcepub fn set_password_autosave_enabled(&self, value: bool) -> Result<()>
pub fn set_password_autosave_enabled(&self, value: bool) -> Result<()>
Whether saving and autofilling passwords is enabled.
Sourcepub fn is_pinch_zoom_enabled(&self) -> Result<bool>
pub fn is_pinch_zoom_enabled(&self) -> Result<bool>
Whether pinch-zoom (touch and trackpad) is enabled.
Sourcepub fn set_pinch_zoom_enabled(&self, value: bool) -> Result<()>
pub fn set_pinch_zoom_enabled(&self, value: bool) -> Result<()>
Whether pinch-zoom (touch and trackpad) is enabled.
Whether swipe gestures navigate back and forward.
Whether swipe gestures navigate back and forward.
Sourcepub fn is_non_client_region_support_enabled(&self) -> Result<bool>
pub fn is_non_client_region_support_enabled(&self) -> Result<bool>
Whether elements styled with app-region: drag are treated as
draggable non-client regions, letting a custom title bar move the host
window.
Sourcepub fn set_non_client_region_support_enabled(&self, value: bool) -> Result<()>
pub fn set_non_client_region_support_enabled(&self, value: bool) -> Result<()>
Whether elements styled with app-region: drag are treated as
draggable non-client regions, letting a custom title bar move the host
window.