pub struct WebView { /* private fields */ }Expand description
A webview showing one page.
The page is built the first time the view is painted, in the window it is painted in, and moves to each other window the view is painted in. It sits at the element’s bounds in every frame the element is painted and is parked in every frame it is not. A parked page stays loaded. A view painted in two windows in turn moves its page on every paint.
The page takes keys while the view’s focus handle is focused, and a press in the page focuses the handle. On macOS, a press on gpui’s view outside the page takes the keys back, whether or not the handle loses focus, and key equivalents (cmd or ctrl held) reach gpui’s key dispatch before the page sees them. On Windows, a key with ctrl or alt held, or a function key, goes to gpui’s key dispatch in place of the page when the keymap binds it in the view’s key context.
gpui elements behind the page are not hovered, and gpui’s cursor over the page is the arrow. On macOS the page sets the cursor over itself.
In a frame where a ui::cover recorded after the view overlaps it, the
page is parked. On macOS a still of the page, taken while it is still up,
is painted in its place; until the still arrives the page stays over the
cover. Elsewhere the place is left empty.
Linux needs gpui on X11 and paints nothing under Wayland. Paints nothing off macOS, Windows and Linux.
Implementations§
Source§impl WebView
impl WebView
pub fn new( url: impl Into<String>, window: &mut Window, cx: &mut Context<'_, Self>, ) -> Self
Sourcepub fn location(&self) -> Option<&str>
pub fn location(&self) -> Option<&str>
The URL the page last reported; None before its first report.
pub fn title(&self) -> &str
pub fn is_loading(&self) -> bool
Sourcepub fn with_user_agent(self, user_agent: impl Into<String>) -> Self
pub fn with_user_agent(self, user_agent: impl Into<String>) -> Self
The user agent the page is built with, in place of the platform’s. Read at the first paint. On macOS the default is Safari’s, with the installed Safari’s version.
Sourcepub fn load(&mut self, url: impl Into<String>)
pub fn load(&mut self, url: impl Into<String>)
Before the first paint, replaces the URL the page is built with. After it, navigates the page.
Sourcepub fn release_keys(&self)
pub fn release_keys(&self)
Takes the keys back from the page if it holds them, whatever gpui’s focus is.
pub fn back(&mut self)
pub fn forward(&mut self)
pub fn reload(&mut self)
Trait Implementations§
impl EventEmitter<WebViewEvent> for WebView
Source§impl Focusable for WebView
impl Focusable for WebView
Source§fn focus_handle(&self, _cx: &App) -> FocusHandle
fn focus_handle(&self, _cx: &App) -> FocusHandle
Auto Trait Implementations§
impl !RefUnwindSafe for WebView
impl !Send for WebView
impl !Sync for WebView
impl !UnwindSafe for WebView
impl Freeze for WebView
impl Unpin for WebView
impl UnsafeUnpin for WebView
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more