Skip to main content

Settings

Struct Settings 

Source
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

Source

pub fn is_script_enabled(&self) -> bool

Whether running JavaScript is enabled.

Source

pub fn set_script_enabled(&self, value: bool) -> Result<()>

Whether running JavaScript is enabled.

Source

pub fn is_web_message_enabled(&self) -> bool

Whether communicating with the host via postMessage is enabled.

Source

pub fn set_web_message_enabled(&self, value: bool) -> Result<()>

Whether communicating with the host via postMessage is enabled.

Source

pub fn are_default_script_dialogs_enabled(&self) -> bool

Whether the default JavaScript dialogs (alert, confirm, prompt, beforeunload) are shown.

Source

pub fn set_default_script_dialogs_enabled(&self, value: bool) -> Result<()>

Whether the default JavaScript dialogs (alert, confirm, prompt, beforeunload) are shown.

Source

pub fn is_status_bar_enabled(&self) -> bool

Whether the status bar is displayed.

Source

pub fn set_status_bar_enabled(&self, value: bool) -> Result<()>

Whether the status bar is displayed.

Source

pub fn are_dev_tools_enabled(&self) -> bool

Whether the browser dev tools are available.

Source

pub fn set_dev_tools_enabled(&self, value: bool) -> Result<()>

Whether the browser dev tools are available.

Source

pub fn are_default_context_menus_enabled(&self) -> bool

Whether the default right-click context menus are shown.

Source

pub fn set_default_context_menus_enabled(&self, value: bool) -> Result<()>

Whether the default right-click context menus are shown.

Source

pub fn are_host_objects_allowed(&self) -> bool

Whether host objects added via the WebView2 host-object APIs are accessible from the page.

Source

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.

Source

pub fn is_zoom_control_enabled(&self) -> bool

Whether zoom control (for example Ctrl++/-) is enabled.

Source

pub fn set_zoom_control_enabled(&self, value: bool) -> Result<()>

Whether zoom control (for example Ctrl++/-) is enabled.

Source

pub fn is_built_in_error_page_enabled(&self) -> bool

Whether the built-in error page is shown for navigation and rendering failures.

Source

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.

Source

pub fn user_agent(&self) -> Result<String>

Returns the user-agent string sent with requests and reported to script.

Source

pub fn set_user_agent(&self, user_agent: &str) -> Result<()>

Overrides the user-agent string sent with requests and reported to script.

Source

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.

Source

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.

Source

pub fn is_general_autofill_enabled(&self) -> Result<bool>

Whether general form autofill (names, addresses, and similar) is enabled.

Source

pub fn set_general_autofill_enabled(&self, value: bool) -> Result<()>

Whether general form autofill (names, addresses, and similar) is enabled.

Source

pub fn is_password_autosave_enabled(&self) -> Result<bool>

Whether saving and autofilling passwords is enabled.

Source

pub fn set_password_autosave_enabled(&self, value: bool) -> Result<()>

Whether saving and autofilling passwords is enabled.

Source

pub fn is_pinch_zoom_enabled(&self) -> Result<bool>

Whether pinch-zoom (touch and trackpad) is enabled.

Source

pub fn set_pinch_zoom_enabled(&self, value: bool) -> Result<()>

Whether pinch-zoom (touch and trackpad) is enabled.

Source

pub fn is_swipe_navigation_enabled(&self) -> Result<bool>

Whether swipe gestures navigate back and forward.

Source

pub fn set_swipe_navigation_enabled(&self, value: bool) -> Result<()>

Whether swipe gestures navigate back and forward.

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.