pub struct BrowserState { /* private fields */ }Expand description
A browser: a tab strip, back, forward and reload buttons, an address
field, and the selected tab’s page in a WebFrame.
It is a view that fills its parent: open it with
BrowserState::open and place the entity as a child. It repaints
itself when a tab opens, closes or changes. It always has at least one
tab, since closing the last one opens the home page again. The pages
are native views, so the same limits as WebView apply.
Implementations§
Source§impl BrowserState
impl BrowserState
Sourcepub fn open(
home: impl Into<SharedString>,
window: &mut Window,
cx: &mut App,
) -> Result<Entity<Self>>
pub fn open( home: impl Into<SharedString>, window: &mut Window, cx: &mut App, ) -> Result<Entity<Self>>
A browser with one tab on home, which a new tab opens as well.
§Errors
If the platform cannot create the first native web view. See
WebView::build for the setup each platform needs.
Sourcepub fn open_tab(
&mut self,
url: impl Into<String>,
window: &mut Window,
cx: &mut Context<'_, Self>,
) -> Result<SharedString>
pub fn open_tab( &mut self, url: impl Into<String>, window: &mut Window, cx: &mut Context<'_, Self>, ) -> Result<SharedString>
Opens a tab on url and selects it. Returns its id.
§Errors
If the browser holds 32 tabs, or the platform cannot create the native web view.
Navigates the selected tab. Text with a scheme loads as it is, text
that looks like a host gets https://, and anything else is a web
search.
Sourcepub fn forward(&mut self, cx: &mut Context<'_, Self>)
pub fn forward(&mut self, cx: &mut Context<'_, Self>)
Goes forward in the selected tab’s history.
Sourcepub fn close_tab(
&mut self,
id: impl Into<SharedString>,
cx: &mut Context<'_, Self>,
)
pub fn close_tab( &mut self, id: impl Into<SharedString>, cx: &mut Context<'_, Self>, )
Closes the tab with id.
Sourcepub fn url(&self, cx: &App) -> Option<SharedString>
pub fn url(&self, cx: &App) -> Option<SharedString>
The address of the selected tab, if there is one.
Trait Implementations§
impl EventEmitter<BrowserEvent> for BrowserState
Source§impl Render for BrowserState
impl Render for BrowserState
Auto Trait Implementations§
impl !RefUnwindSafe for BrowserState
impl !Send for BrowserState
impl !Sync for BrowserState
impl !UnwindSafe for BrowserState
impl Freeze for BrowserState
impl Unpin for BrowserState
impl UnsafeUnpin for BrowserState
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.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