Struct scl_webview::WebView

source ·
pub struct WebView { /* private fields */ }
Expand description

一个可以显示单个浏览器窗口的对象

通过设置链接回调来获取对应的链接

Implementations§

source§

impl WebView

source

pub fn new() -> Self

创建一个默认空白页面的 WebView

source

pub fn set_fixed_size(&mut self, s: (u32, u32))

固定窗口大小

source

pub fn fixed_size(self, s: (u32, u32)) -> Self

固定窗口大小

source

pub fn set_on_url_change(&mut self, f: fn(_: &str) -> bool)

设置一个链接变更回调函数,如果函数返回 true 则会关闭 WebView 并返回该链接

反之则继续运行 WebView

source

pub fn begin_url(self, url: String) -> Self

设置第一个打开的链接

source

pub fn set_begin_url(&mut self, url: String)

设置第一个打开的链接

source

pub fn on_url_change(self, f: fn(_: &str) -> bool) -> Self

设置一个链接变更回调函数,如果函数返回 true 则会关闭 WebView 并返回该链接

反之则继续运行 WebView

source

pub fn set_title(&mut self, title: String)

设置窗口标题

source

pub fn title(self, title: String) -> Self

设置窗口标题

source

pub fn run(&mut self) -> DynResult<String>

阻塞当前线程运行 WebView,当发生链接改变且已经设置回调函数时,将会返回退出时正在访问的链接

如果是用户关闭了窗口或发生其它情况,则返回空字符串

Trait Implementations§

source§

impl Default for WebView

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.