pub struct WebView { /* private fields */ }Expand description
An embeddable web view. Composing widget: it delegates layout/paint to a style-built overlay and drives a native engine subview on top.
See the crate docs for the dormancy/visibility contract.
Implementations§
Source§impl WebView
impl WebView
Sourcepub fn user_agent(self, ua: impl Into<String>) -> Self
pub fn user_agent(self, ua: impl Into<String>) -> Self
Override the engine User-Agent.
Sourcepub fn transparent(self, transparent: bool) -> Self
pub fn transparent(self, transparent: bool) -> Self
Request a transparent engine background.
Sourcepub fn devtools(self, devtools: bool) -> Self
pub fn devtools(self, devtools: bool) -> Self
Enable engine devtools (debug builds, by convention).
Sourcepub fn custom_protocol(self, scheme: impl Into<String>) -> Self
pub fn custom_protocol(self, scheme: impl Into<String>) -> Self
Register a custom-protocol scheme name ("app" → app://). The
dispatch closure lives app-side; the backend only needs the name.
Sourcepub fn url_signal(self, signal: Signal<String>) -> Self
pub fn url_signal(self, signal: Signal<String>) -> Self
Two-way URL binding. The engine writes the resolved URL into signal
when an in-page navigation completes; calling signal.set("…")
externally drives programmatic navigation (equivalent to
load_url). The engine’s own echo is filtered, so
the two directions don’t loop.
The initial page still comes from url /
html / source; url_signal governs
navigation after the first load (the signal’s value at build time is
taken as the baseline and does not trigger a navigation).
Sourcepub fn title_signal(self, signal: Signal<String>) -> Self
pub fn title_signal(self, signal: Signal<String>) -> Self
Bind the page title (read-only — updated on TitleChanged).
Sourcepub fn loading_signal(self, signal: Signal<bool>) -> Self
pub fn loading_signal(self, signal: Signal<bool>) -> Self
Bind the loading flag (read-only — true between page-load start/finish).
Sourcepub fn on_message(
self,
cb: impl FnMut(String, &mut EventContext<'_>) + 'static,
) -> Self
pub fn on_message( self, cb: impl FnMut(String, &mut EventContext<'_>) + 'static, ) -> Self
JS → Rust: called when the page runs window.ipc.postMessage(...).
Sourcepub fn on_title_changed(
self,
cb: impl FnMut(String, &mut EventContext<'_>) + 'static,
) -> Self
pub fn on_title_changed( self, cb: impl FnMut(String, &mut EventContext<'_>) + 'static, ) -> Self
Called when the document title changes.
Called when a navigation starts (observer — see NavigationInfo; it
cannot veto). Useful for URL-bar sync before the load completes.
Sourcepub fn on_page_load(
self,
cb: impl FnMut(PageLoadState, &mut EventContext<'_>) + 'static,
) -> Self
pub fn on_page_load( self, cb: impl FnMut(PageLoadState, &mut EventContext<'_>) + 'static, ) -> Self
Called when page loading starts and finishes (see PageLoadState).
Sourcepub fn on_download_started(
self,
cb: impl FnMut(DownloadStart, &mut EventContext<'_>) + 'static,
) -> Self
pub fn on_download_started( self, cb: impl FnMut(DownloadStart, &mut EventContext<'_>) + 'static, ) -> Self
Called when the page begins a download (see DownloadStart).
Sourcepub fn on_download_finished(
self,
cb: impl FnMut(DownloadOutcome, &mut EventContext<'_>) + 'static,
) -> Self
pub fn on_download_finished( self, cb: impl FnMut(DownloadOutcome, &mut EventContext<'_>) + 'static, ) -> Self
Called when a download finishes or fails (see DownloadOutcome).
Sourcepub fn style(self, style: impl WebViewStyle) -> Self
pub fn style(self, style: impl WebViewStyle) -> Self
Per-call style override (highest precedence).
Sourcepub fn enter_page_on_focus(self, enter: bool) -> Self
pub fn enter_page_on_focus(self, enter: bool) -> Self
Enter the page as soon as the frame receives keyboard focus, rather than on Enter (the default two-step).
Only appropriate when the web view is the window’s content and there is nothing else in the Tab cycle worth reaching — a kiosk view, a full-window document preview. In a mixed UI it makes Tab a one-way door: once the engine owns the keyboard, Teksilo sees no more keys and getting back out is up to the engine and the OS. Off by default for exactly that reason.
Sourcepub fn input_mode(self, input: WebViewInput) -> Self
pub fn input_mode(self, input: WebViewInput) -> Self
Declare who owns pointer input over the page’s rectangle.
WebViewInput::Native — the default — gives it to the engine;
WebViewInput::Transparent keeps it for Teksilo. See
WebViewInput for everything the choice decides.
Sourcepub fn page_focused_signal(&self) -> Signal<bool>
pub fn page_focused_signal(&self) -> Signal<bool>
Whether the page currently holds the engine’s keyboard focus.
Written from WebViewEvent::EngineFocusChanged, which is the only
thing that can know: once the native subview owns the keyboard, the
toolkit is told nothing more about what happens inside it. Distinct
from focused_signal, which reports Teksilo’s
own focus on the frame.
Sourcepub fn focus_page(&self)
pub fn focus_page(&self)
Hand keyboard focus to the engine subview, entering the page.
The programmatic form of the frame’s Enter key. No-op before the engine has opened (the handle is created post-mount).
Sourcepub fn focused_signal(&self) -> Signal<bool>
pub fn focused_signal(&self) -> Signal<bool>
Whether the Teksilo-side frame currently holds keyboard focus.
True while Tab has landed on the web view; it says nothing about whether the page has been entered, because once the engine subview owns the keyboard the toolkit is no longer told what happens inside it.
Sourcepub fn post_message(&self, msg: &str)
pub fn post_message(&self, msg: &str)
Rust → JS: dispatch a teksilo-message event carrying msg.
Sourcepub fn go_forward(&self)
pub fn go_forward(&self)
Navigate forward.
Sourcepub fn open_devtools(&self)
pub fn open_devtools(&self)
Open the engine’s developer tools (no-op where unsupported, e.g. Servo).
Sourcepub fn close_devtools(&self)
pub fn close_devtools(&self)
Close the engine’s developer tools.
Trait Implementations§
Source§impl Widget for WebView
impl Widget for WebView
Source§fn build(&mut self, ctx: &mut BuildContext<'_>) -> Vec<WidgetId>
fn build(&mut self, ctx: &mut BuildContext<'_>) -> Vec<WidgetId>
BindingLevel::Rebuild binding, rebuild_single_widget, or a density
switch. A theme or locale switch does not rebuild: set_theme and
set_locale mark layout + paint dirty and leave the built subtree
standing, so anything derived from the theme or the locale must be read
per pass or bound to a signal rather than captured here.
Takes &mut self — store child IDs, signal handles, any state needed later.
Returns the list of root child IDs (empty for leaf widgets).Source§fn layout_response(
&self,
proposal: SizeProposal,
ctx: &LayoutContext<'_>,
) -> LayoutResponse
fn layout_response( &self, proposal: SizeProposal, ctx: &LayoutContext<'_>, ) -> LayoutResponse
LayoutResponse). Read moreSource§fn place_children(
&self,
bounds: Rect,
_proposal: SizeProposal,
children: &mut [WidgetPlacement],
ctx: &LayoutContext<'_>,
)
fn place_children( &self, bounds: Rect, _proposal: SizeProposal, children: &mut [WidgetPlacement], ctx: &LayoutContext<'_>, )
Source§fn wants_after_paint(&self) -> bool
fn wants_after_paint(&self) -> bool
after_paint
hook to fire each frame. Returning false (the default) saves
a virtual call per widget per frame for the vast majority of
widgets that don’t aggregate descendant geometry. Read moreSource§fn after_paint(&self, view: &WidgetTreeView<'_>, _ctx: &PaintContext<'_>)
fn after_paint(&self, view: &WidgetTreeView<'_>, _ctx: &PaintContext<'_>)
TitleBar aggregates its drag region and control-button
rects into a single HitRegions payload for the Windows
backend’s WM_NCHITTEST. Read moreSource§fn accessibility(&self, builder: &mut AccessNodeBuilder)
fn accessibility(&self, builder: &mut AccessNodeBuilder)
Source§fn as_any_mut(&mut self) -> Option<&mut dyn Any>
fn as_any_mut(&mut self) -> Option<&mut dyn Any>
as_any. Default
returns None; widgets that want to expose mutable state to
tests (e.g. so a test can mutate a Scene inside a
SceneView post-layout) override with Some(self). Should
follow the same opt-in pattern as as_any: only widgets
that opt into & introspection should opt into &mut.Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
"teksilo_widgets::button::Button"). The default implementation
resolves at the impl site via std::any::type_name::<Self>(),
so calls through &dyn Widget correctly dispatch to the
monomorphized fn for the concrete type — getting the
concrete name through the vtable without per-impl boilerplate. Read moreSource§fn cacheable_layout(&self) -> bool
fn cacheable_layout(&self) -> bool
layout_response may be
memoized by the per-pass layout cache. Defaults to true. Read moreSource§fn paint(&self, _bounds: Rect, _canvas: &mut Canvas, _ctx: &PaintContext<'_>)
fn paint(&self, _bounds: Rect, _canvas: &mut Canvas, _ctx: &PaintContext<'_>)
Source§fn wants_post_paint(&self) -> bool
fn wants_post_paint(&self) -> bool
post_paint
hook to fire each frame. Returning false (the default) saves a
virtual call per widget per frame for the vast majority of widgets
that don’t draw a foreground over their children. Read moreSource§fn post_paint(
&self,
_bounds: Rect,
_canvas: &mut Canvas,
_ctx: &PaintContext<'_>,
)
fn post_paint( &self, _bounds: Rect, _canvas: &mut Canvas, _ctx: &PaintContext<'_>, )
Source§fn wants_descendant_redirects(&self) -> bool
fn wants_descendant_redirects(&self) -> bool
a11y_redirect_descendant
hook for every descendant during AT tree emission, not
just its direct arena children. Read moreSource§fn culls_children(&self) -> bool
fn culls_children(&self) -> bool
Source§fn a11y_redirect_descendant(
&self,
_self_id: WidgetId,
_descendant: WidgetId,
) -> Option<NodeId>
fn a11y_redirect_descendant( &self, _self_id: WidgetId, _descendant: WidgetId, ) -> Option<NodeId>
Source§fn accessible_title_hint(&self) -> Option<String>
fn accessible_title_hint(&self) -> Option<String>
Source§fn accessible_title_node(&self) -> Option<WidgetId>
fn accessible_title_node(&self) -> Option<WidgetId>
Source§fn initial_focus_hint(&self) -> Option<WidgetId>
fn initial_focus_hint(&self) -> Option<WidgetId>
Source§fn as_any(&self) -> Option<&(dyn Any + 'static)>
fn as_any(&self) -> Option<&(dyn Any + 'static)>
None; concrete
widgets override with Some(self) when they want to expose
their concrete type to test-level introspection or reflection.
The trait already bounds on std::any::Any so concrete types
satisfy the 'static requirement.Source§fn clips_children(&self) -> bool
fn clips_children(&self) -> bool
Source§fn focus_reveal_rect(&self, _bounds: Rect) -> Option<Rect>
fn focus_reveal_rect(&self, _bounds: Rect) -> Option<Rect>
None (the default) reveals the widget’s whole
bounds — correct for most controls. Read moreSource§fn hit_shape(&self, _local_point: Point, _bounds: Rect) -> bool
fn hit_shape(&self, _local_point: Point, _bounds: Rect) -> bool
false for a point that is inside
the bounding box makes the widget transparent to the click there,
so it falls through to whatever sibling is painted underneath
(the same machinery as a fully pass-through node, but shape-aware). Read moreSource§fn accepts_child_hit(&self, _child: WidgetId, _point: Point) -> bool
fn accepts_child_hit(&self, _child: WidgetId, _point: Point) -> bool
Source§fn hit_outset(&self, _kind: PointerKind, _tokens: &InputTokens) -> EdgeInsets
fn hit_outset(&self, _kind: PointerKind, _tokens: &InputTokens) -> EdgeInsets
Source§fn hit_slop(&self, _kind: PointerKind, _tokens: &InputTokens) -> Option<HitSlop>
fn hit_slop(&self, _kind: PointerKind, _tokens: &InputTokens) -> Option<HitSlop>
Source§fn hit_distance(&self, local_point: Point, bounds: Rect) -> Option<f32>
fn hit_distance(&self, local_point: Point, bounds: Rect) -> Option<f32>
Source§fn target_regions(&self, _bounds: Rect) -> Vec<TargetRegion>
fn target_regions(&self, _bounds: Rect) -> Vec<TargetRegion>
Source§fn preserves_children_on_rebuild(&self) -> bool
fn preserves_children_on_rebuild(&self) -> bool
rebuild_single_widget treats this widget’s existing children
when re-running its build(). Read moreSource§fn tooltip_has_content(&self) -> bool
fn tooltip_has_content(&self) -> bool
Source§fn declare_shortcuts(&self) -> Vec<Shortcut>
fn declare_shortcuts(&self) -> Vec<Shortcut>
build()) and at certain lazy
boundaries (e.g. Switcher walks declarations on its
not-yet-mounted Pending slots), so settings UIs and the
ShortcutRegistry see the keystrokes the moment the owning
container mounts — even if build() hasn’t run. Read moreSource§fn take_handler_set(&mut self) -> Option<HandlerSet>
fn take_handler_set(&mut self) -> Option<HandlerSet>
WidgetWithHandlers wrapper.
Called during arena insertion to transfer handlers to the WidgetNode.
Default: returns None (no attached handlers).Auto Trait Implementations§
impl !Freeze for WebView
impl !RefUnwindSafe for WebView
impl !Send for WebView
impl !Sync for WebView
impl !UnwindSafe 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
Source§impl<W> IntoTeksiChild for Wwhere
W: Widget + 'static,
impl<W> IntoTeksiChild for Wwhere
W: Widget + 'static,
fn into_pending(self) -> PendingChild
Source§impl<W> WidgetBuilder for Wwhere
W: Widget + 'static,
impl<W> WidgetBuilder for Wwhere
W: Widget + 'static,
fn on_tap( self, f: impl FnMut(&TapEvent, &mut EventContext<'_>) + 'static, ) -> WidgetWithHandlers<Self>
fn on_double_tap( self, f: impl FnMut(&TapEvent, &mut EventContext<'_>) + 'static, ) -> WidgetWithHandlers<Self>
fn on_triple_tap( self, f: impl FnMut(&TapEvent, &mut EventContext<'_>) + 'static, ) -> WidgetWithHandlers<Self>
fn on_long_press( self, f: impl FnMut(&TapEvent, &mut EventContext<'_>) + 'static, ) -> WidgetWithHandlers<Self>
on_tap. Default is ButtonMask::PRIMARY.on_double_tap. Default ButtonMask::PRIMARY.on_triple_tap. Default ButtonMask::PRIMARY.on_long_press. Default ButtonMask::PRIMARY.fn on_drag( self, f: impl FnMut(DragPhase, &mut EventContext<'_>) + 'static, ) -> WidgetWithHandlers<Self>
fn on_swipe( self, f: impl FnMut(SwipeDirection, f32, &mut EventContext<'_>) + 'static, ) -> WidgetWithHandlers<Self>
fn on_pinch( self, f: impl FnMut(PinchPhase, &mut EventContext<'_>) + 'static, ) -> WidgetWithHandlers<Self>
fn on_focus( self, f: impl FnMut(bool, &mut EventContext<'_>) + 'static, ) -> WidgetWithHandlers<Self>
fn on_key( self, f: impl FnMut(&WidgetEvent, &mut EventContext<'_>) -> EventResponse + 'static, ) -> WidgetWithHandlers<Self>
Source§fn on_key_preview(
self,
f: impl FnMut(&WidgetEvent, &mut EventContext<'_>) -> EventResponse + 'static,
) -> WidgetWithHandlers<Self>
fn on_key_preview( self, f: impl FnMut(&WidgetEvent, &mut EventContext<'_>) -> EventResponse + 'static, ) -> WidgetWithHandlers<Self>
HandlerSet::on_key_preview.fn on_pointer_event( self, f: impl FnMut(&WidgetEvent, &mut EventContext<'_>) -> EventResponse + 'static, ) -> WidgetWithHandlers<Self>
fn on_hover( self, f: impl FnMut(bool, &mut EventContext<'_>) + 'static, ) -> WidgetWithHandlers<Self>
fn on_scroll( self, f: impl FnMut(&WidgetEvent, &mut EventContext<'_>) -> EventResponse + 'static, ) -> WidgetWithHandlers<Self>
fn on_access_action( self, f: impl FnMut(Action, &mut EventContext<'_>) -> EventResponse + 'static, ) -> WidgetWithHandlers<Self>
fn focusable(self, focusable: bool) -> WidgetWithHandlers<Self>
fn tab_index(self, index: i32) -> WidgetWithHandlers<Self>
fn cursor(self, cursor: CursorIcon) -> WidgetWithHandlers<Self>
fn clips_children_on(self, clips: bool) -> WidgetWithHandlers<Self>
Source§fn ime_input(self, ctx: ImeContext) -> WidgetWithHandlers<Self>
fn ime_input(self, ctx: ImeContext) -> WidgetWithHandlers<Self>
ctx’s purpose) while it is focused. See crate::ime.Source§fn event_pass_through(self, pass_through: bool) -> WidgetWithHandlers<Self>
fn event_pass_through(self, pass_through: bool) -> WidgetWithHandlers<Self>
HandlerSet::event_pass_through.Source§fn gesture_dead_zone(self, dead_zone: bool) -> WidgetWithHandlers<Self>
fn gesture_dead_zone(self, dead_zone: bool) -> WidgetWithHandlers<Self>
HandlerSet::gesture_dead_zone.Source§fn long_press_role(self, role: LongPressRole) -> WidgetWithHandlers<Self>
fn long_press_role(self, role: LongPressRole) -> WidgetWithHandlers<Self>
HandlerSet::long_press_role.Source§fn touch_action(self, action: TouchAction) -> WidgetWithHandlers<Self>
fn touch_action(self, action: TouchAction) -> WidgetWithHandlers<Self>
HandlerSet::touch_action.Source§fn scroll_container(self, axes: PanAxes) -> WidgetWithHandlers<Self>
fn scroll_container(self, axes: PanAxes) -> WidgetWithHandlers<Self>
axes, kinetic, direct pointers
only. See HandlerSet::scroll_container.Source§fn pan_claim(self, claim: PanClaim) -> WidgetWithHandlers<Self>
fn pan_claim(self, claim: PanClaim) -> WidgetWithHandlers<Self>
PanClaim. See
HandlerSet::pan_claim.Source§fn overscroll_behavior(
self,
behavior: OverscrollBehavior,
) -> WidgetWithHandlers<Self>
fn overscroll_behavior( self, behavior: OverscrollBehavior, ) -> WidgetWithHandlers<Self>
HandlerSet::overscroll_behavior.Source§fn drag_activation(self, activation: DragActivation) -> WidgetWithHandlers<Self>
fn drag_activation(self, activation: DragActivation) -> WidgetWithHandlers<Self>
HandlerSet::drag_activation.Source§fn multi_contact(self, policy: MultiContact) -> WidgetWithHandlers<Self>
fn multi_contact(self, policy: MultiContact) -> WidgetWithHandlers<Self>
MultiContact::First — the second finger on a single-contact control
is terminated there rather than reaching an ancestor.Source§fn keyboard_capture(self, capture: bool) -> WidgetWithHandlers<Self>
fn keyboard_capture(self, capture: bool) -> WidgetWithHandlers<Self>
KeyDowns bypass shortcut resolution.
See HandlerSet::keyboard_capture.Source§fn hit_transparent(self, transparent: bool) -> WidgetWithHandlers<Self>
fn hit_transparent(self, transparent: bool) -> WidgetWithHandlers<Self>
HandlerSet::hit_transparent.Source§fn hit_slop(self, slop: HitSlop) -> WidgetWithHandlers<Self>
fn hit_slop(self, slop: HitSlop) -> WidgetWithHandlers<Self>
HandlerSet::hit_slop.Source§fn no_hit_slop(self) -> WidgetWithHandlers<Self>
fn no_hit_slop(self) -> WidgetWithHandlers<Self>
Widget::hit_outset. See HandlerSet::no_hit_slop.HandlerSet::context_menu for the full contract.Source§fn focus_within(self, signal: Signal<bool>) -> WidgetWithHandlers<Self>
fn focus_within(self, signal: Signal<bool>) -> WidgetWithHandlers<Self>
Signal<bool> the framework writes when a strict
descendant has focus. See HandlerSet::focus_within.Source§fn hover_within(self, signal: Signal<bool>) -> WidgetWithHandlers<Self>
fn hover_within(self, signal: Signal<bool>) -> WidgetWithHandlers<Self>
Signal<bool> the framework writes when a strict
descendant is hovered. See HandlerSet::hover_within.Source§fn visible_when(self, state: impl Into<Prop<bool>>) -> WidgetWithHandlers<Self>
fn visible_when(self, state: impl Into<Prop<bool>>) -> WidgetWithHandlers<Self>
bool / Signal<bool> / Prop<bool>) as
a builder property, so teksu! can write visible_when: sig. Equivalent
to ctx.visible_when(id, ..). See HandlerSet::visible_when.fn on_drag_hover( self, f: impl FnMut(&DragPayload, Point, &mut EventContext<'_>) -> DropFeedback + 'static, ) -> WidgetWithHandlers<Self>
fn on_drag_leave( self, f: impl FnMut(&mut EventContext<'_>) + 'static, ) -> WidgetWithHandlers<Self>
fn on_drag_tick( self, f: impl FnMut(Point, &mut EventContext<'_>) + 'static, ) -> WidgetWithHandlers<Self>
Source§fn on_pointer_cancel(
self,
f: impl FnMut(&PointerInfo, CancelReason, &mut EventContext<'_>) + 'static,
) -> WidgetWithHandlers<Self>
fn on_pointer_cancel( self, f: impl FnMut(&PointerInfo, CancelReason, &mut EventContext<'_>) + 'static, ) -> WidgetWithHandlers<Self>
HandlerSet::on_pointer_cancel.fn on_drop( self, f: impl FnMut(DragPayload, Point, &mut EventContext<'_>) -> bool + 'static, ) -> WidgetWithHandlers<Self>
Source§fn on_drag_ended(
self,
f: impl FnMut(DropOutcome, &mut EventContext<'_>) + 'static,
) -> WidgetWithHandlers<Self>
fn on_drag_ended( self, f: impl FnMut(DropOutcome, &mut EventContext<'_>) + 'static, ) -> WidgetWithHandlers<Self>
HandlerSet::on_drag_ended.