Struct tauri::window::Window
pub struct Window<R: Runtime = Wry> { /* fields omitted */ }
Expand description
A webview window managed by Tauri.
This type also implements Manager
which allows you to manage other windows attached to the same application.
#
ImplementationsRuntime> Window<R>[src]#
impl<R:create_window<F>( &mut self, label: String, url: WindowUrl, setup: F ) -> Result<Window<R>> where F: FnOnce(<R::Dispatcher as Dispatch>::WindowBuilder, WebviewAttributes) -> (<R::Dispatcher as Dispatch>::WindowBuilder, WebviewAttributes),[src]#
pub fnCreates a new webview window.
label(&self) -> &str[src]#
pub fnThe label of this window.
emit<S: Serialize>(&self, event: &str, payload: S) -> Result<()>[src]#
pub fnEmits an event to the current window.
emit_others<S: Serialize + Clone>( &self, event: &str, payload: S ) -> Result<()>[src]#
pub fnEmits an event on all windows except this one.
listen<F>(&self, event: impl Into<String>, handler: F) -> EventHandler where F: Fn(Event) + Send + 'static,[src]#
pub fnListen to an event on this window.
once<F>(&self, event: impl Into<String>, handler: F) -> EventHandler where F: Fn(Event) + Send + 'static,[src]#
pub fnListen to a an event on this window a single time.
trigger(&self, event: &str, data: Option<String>)[src]#
pub fnTriggers an event on this window.
eval(&self, js: &str) -> Result<()>[src]#
pub fnEvaluates JavaScript on this window.
on_window_event<F: Fn(&WindowEvent) + Send + 'static>(&self, f: F)[src]#
pub fnRegisters a window event listener.
on_menu_event<F: Fn(MenuEvent) + Send + 'static>(&self, f: F) -> Uuid[src]#
pub fnRegisters a menu event listener.
menu_handle(&self) -> MenuHandle<R>[src]#
pub fnGets a handle to the window menu.
scale_factor(&self) -> Result<f64>[src]#
pub fnReturns the scale factor that can be used to map logical pixels to physical pixels, and vice versa.
#
Panics- Panics if the event loop is not running yet, usually when called on the
setup
closure. - Panics when called on the main thread, usually on the
run
closure.
You can spawn a task to use the API using crate::async_runtime::spawn
or std::thread::spawn
to prevent the panic.
inner_position(&self) -> Result<PhysicalPosition<i32>>[src]#
pub fnReturns the position of the top-left hand corner of the window’s client area relative to the top-left hand corner of the desktop.
#
Panics- Panics if the event loop is not running yet, usually when called on the
setup
closure. - Panics when called on the main thread, usually on the
run
closure.
You can spawn a task to use the API using crate::async_runtime::spawn
or std::thread::spawn
to prevent the panic.
outer_position(&self) -> Result<PhysicalPosition<i32>>[src]#
pub fnReturns the position of the top-left hand corner of the window relative to the top-left hand corner of the desktop.
#
Panics- Panics if the event loop is not running yet, usually when called on the
setup
closure. - Panics when called on the main thread, usually on the
run
closure.
You can spawn a task to use the API using crate::async_runtime::spawn
or std::thread::spawn
to prevent the panic.
inner_size(&self) -> Result<PhysicalSize<u32>>[src]#
pub fnReturns the physical size of the window’s client area.
The client area is the content of the window, excluding the title bar and borders.
#
Panics- Panics if the event loop is not running yet, usually when called on the
setup
closure. - Panics when called on the main thread, usually on the
run
closure.
You can spawn a task to use the API using crate::async_runtime::spawn
or std::thread::spawn
to prevent the panic.
outer_size(&self) -> Result<PhysicalSize<u32>>[src]#
pub fnReturns the physical size of the entire window.
These dimensions include the title bar and borders. If you don’t want that (and you usually don’t), use inner_size instead.
#
Panics- Panics if the event loop is not running yet, usually when called on the
setup
closure. - Panics when called on the main thread, usually on the
run
closure.
You can spawn a task to use the API using crate::async_runtime::spawn
or std::thread::spawn
to prevent the panic.
is_fullscreen(&self) -> Result<bool>[src]#
pub fnGets the window’s current fullscreen state.
#
Panics- Panics if the event loop is not running yet, usually when called on the
setup
closure. - Panics when called on the main thread, usually on the
run
closure.
You can spawn a task to use the API using crate::async_runtime::spawn
or std::thread::spawn
to prevent the panic.
is_maximized(&self) -> Result<bool>[src]#
pub fnGets the window’s current maximized state.
#
Panics- Panics if the event loop is not running yet, usually when called on the
setup
closure. - Panics when called on the main thread, usually on the
run
closure.
You can spawn a task to use the API using crate::async_runtime::spawn
or std::thread::spawn
to prevent the panic.
is_decorated(&self) -> Result<bool>[src]#
pub fnGets the window’s current decoration state.
#
Panics- Panics if the event loop is not running yet, usually when called on the
setup
closure. - Panics when called on the main thread, usually on the
run
closure.
You can spawn a task to use the API using crate::async_runtime::spawn
or std::thread::spawn
to prevent the panic.
is_resizable(&self) -> Result<bool>[src]#
pub fnGets the window’s current resizable state.
#
Panics- Panics if the event loop is not running yet, usually when called on the
setup
closure. - Panics when called on the main thread, usually on the
run
closure.
You can spawn a task to use the API using crate::async_runtime::spawn
or std::thread::spawn
to prevent the panic.
is_visible(&self) -> Result<bool>[src]#
pub fnGets the window’s current vibility state.
#
Panics- Panics if the event loop is not running yet, usually when called on the
setup
closure. - Panics when called on the main thread, usually on the
run
closure.
You can spawn a task to use the API using crate::async_runtime::spawn
or std::thread::spawn
to prevent the panic.
current_monitor(&self) -> Result<Option<Monitor>>[src]#
pub fnReturns the monitor on which the window currently resides.
Returns None if current monitor can’t be detected.
Platform-specific#
- Linux: Unsupported
#
Panics- Panics if the event loop is not running yet, usually when called on the
setup
closure. - Panics when called on the main thread, usually on the
run
closure.
You can spawn a task to use the API using crate::async_runtime::spawn
or std::thread::spawn
to prevent the panic.
primary_monitor(&self) -> Result<Option<Monitor>>[src]#
pub fnReturns the primary monitor of the system.
Returns None if it can’t identify any monitor as a primary one.
Platform-specific#
- Linux: Unsupported
#
Panics- Panics if the event loop is not running yet, usually when called on the
setup
closure. - Panics when called on the main thread, usually on the
run
closure.
You can spawn a task to use the API using crate::async_runtime::spawn
or std::thread::spawn
to prevent the panic.
available_monitors(&self) -> Result<Vec<Monitor>>[src]#
pub fnReturns the list of all the monitors available on the system.
Platform-specific#
- Linux: Unsupported
#
Panics- Panics if the event loop is not running yet, usually when called on the
setup
closure. - Panics when called on the main thread, usually on the
run
closure.
You can spawn a task to use the API using crate::async_runtime::spawn
or std::thread::spawn
to prevent the panic.
gtk_window(&self) -> Result<ApplicationWindow>[src]#
pub fnReturns the ApplicatonWindow
from gtk crate that is used by this window.
Note that this can only be used on the main thread.
center(&self) -> Result<()>[src]#
pub fnCenters the window.
request_user_attention( &self, request_type: Option<UserAttentionType> ) -> Result<()>[src]#
pub fnRequests user attention to the window, this has no effect if the application is already focused. How requesting for user attention manifests is platform dependent, see UserAttentionType
for details.
Providing None
will unset the request for user attention. Unsetting the request for user attention might not be done automatically by the WM when the window receives input.
Platform-specific#
- macOS:
None
has no effect.
print(&self) -> Result<()>[src]#
pub fnOpens the dialog to prints the contents of the webview. Currently only supported on macOS on wry
. window.print()
works on all platforms.
set_resizable(&self, resizable: bool) -> Result<()>[src]#
pub fnDetermines if this window should be resizable.
set_title(&self, title: &str) -> Result<()>[src]#
pub fnSet this window’s title.
maximize(&self) -> Result<()>[src]#
pub fnMaximizes this window.
unmaximize(&self) -> Result<()>[src]#
pub fnUn-maximizes this window.
minimize(&self) -> Result<()>[src]#
pub fnMinimizes this window.
unminimize(&self) -> Result<()>[src]#
pub fnUn-minimizes this window.
show(&self) -> Result<()>[src]#
pub fnShow this window.
hide(&self) -> Result<()>[src]#
pub fnHide this window.
close(&self) -> Result<()>[src]#
pub fnCloses this window.
set_decorations(&self, decorations: bool) -> Result<()>[src]#
pub fnDetermines if this window should be decorated.
set_always_on_top(&self, always_on_top: bool) -> Result<()>[src]#
pub fnDetermines if this window should always be on top of other windows.
set_size<S: Into<Size>>(&self, size: S) -> Result<()>[src]#
pub fnResizes this window.
set_min_size<S: Into<Size>>(&self, size: Option<S>) -> Result<()>[src]#
pub fnSets this window’s minimum size.
set_max_size<S: Into<Size>>(&self, size: Option<S>) -> Result<()>[src]#
pub fnSets this window’s maximum size.
set_position<Pos: Into<Position>>(&self, position: Pos) -> Result<()>[src]#
pub fnSets this window’s position.
set_fullscreen(&self, fullscreen: bool) -> Result<()>[src]#
pub fnDetermines if this window should be fullscreen.
set_focus(&self) -> Result<()>[src]#
pub fnBring the window to front and focus.
set_icon(&self, icon: Icon) -> Result<()>[src]#
pub fnSets this window’ icon.
set_skip_taskbar(&self, skip: bool) -> Result<()>[src]#
pub fnWhether to show the window icon in the task bar or not.
start_dragging(&self) -> Result<()>[src]#
pub fnStarts dragging the window.
#
Trait ImplementationsRuntime> Clone for Window<R>[src]#
impl<R:clone(&self) -> Self[src]#
fnReturns a copy of the value. Read more
clone_from(&mut self, source: &Self)1.0.0[src]#
fnPerforms copy-assignment from source
. Read more
Runtime> CommandArg<'de, R> for Window<R>[src]#
impl<'de, R:from_command(command: CommandItem<'de, R>) -> Result<Self, InvokeError>[src]#
fnGrabs the Window
from the CommandItem
. This will never fail.
Debug + Runtime> Debug for Window<R>[src]#
impl<R:fmt(&self, f: &mut Formatter<'_>) -> Result[src]#
fnFormats the value using the given formatter. Read more
Runtime> Hash for Window<R>[src]#
impl<R:hash<H: Hasher>(&self, state: &mutH)[src]#
fnOnly use the Window
’s label to represent its hash.
hash_slice<H>(data: &[Self], state: &mutH) where H: Hasher,1.3.0[src]#
fnFeeds a slice of this type into the given Hasher
. Read more
Runtime> Manager<R> for Window<R>[src]#
impl<R:config(&self) -> Arc<Config>[src]#
fnThe Config
the manager was created with.
emit_all<S: Serialize + Clone>(&self, event: &str, payload: S) -> Result<()>[src]#
fnEmits a event to all windows.
emit_to<S: Serialize + Clone>( &self, label: &str, event: &str, payload: S ) -> Result<()>[src]#
fnEmits an event to a window with the specified label.
listen_global<F>(&self, event: impl Into<String>, handler: F) -> EventHandler where F: Fn(EmittedEvent) + Send + 'static,[src]#
fnListen to a global event.
once_global<F>(&self, event: impl Into<String>, handler: F) -> EventHandler where F: Fn(EmittedEvent) + Send + 'static,[src]#
fnListen to a global event only once.
trigger_global(&self, event: &str, data: Option<String>)[src]#
fnTrigger a global event.
unlisten(&self, handler_id: EventHandler)[src]#
fnRemove an event listener.
get_window(&self, label: &str) -> Option<Window<R>>[src]#
fnFetch a single window from the manager.
windows(&self) -> HashMap<String, Window<R>>[src]#
fnFetch all managed windows.
manage<T>(&self, state: T) where T: Send + Sync + 'static,[src]#
fnAdd state
to the state managed by the application. See crate::Builder
for instructions. Read more
state<T>(&self) -> State<'_, T> where T: Send + Sync + 'static,[src]#
fnGets the managed state for the type T
. Panics if the type is not managed.
try_state<T>(&self) -> Option<State<'_, T>> where T: Send + Sync + 'static,[src]#
fnTries to get the managed state for the type T
. Returns None
if the type is not managed.
Runtime> PartialEq<Window<R>> for Window<R>[src]#
impl<R:eq(&self, other: &Self) -> bool[src]#
fnOnly use the Window
’s label to compare equality.
ne(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests for !=
.
Runtime> Eq for Window<R>#
impl<R:#
Auto Trait ImplementationsWry> \!RefUnwindSafe for Window<R>#
impl<R =Send for Window<R>#
impl<R>Sync for Window<R> where <R as Runtime>::ClipboardManager: Sync, <R as Runtime>::Dispatcher: Sync, <R as Runtime>::GlobalShortcutManager: Sync, <R as Runtime>::Handle: Sync,#
impl<R>Unpin for Window<R> where <R as Runtime>::ClipboardManager: Unpin, <R as Runtime>::Dispatcher: Unpin, <R as Runtime>::GlobalShortcutManager: Unpin, <R as Runtime>::Handle: Unpin,#
impl<R>Wry> \!UnwindSafe for Window<R>#
impl<R =#
Blanket ImplementationsAny for T where T: 'static + ?Sized,[src]#
impl<T>type_id(&self) -> TypeId[src]#
pub fnGets the TypeId
of self
. Read more
Borrow<T> for T where T: ?Sized,[src]#
impl<T>borrow(&self) -> &T[src]#
pub fnImmutably borrows from an owned value. Read more
BorrowMut<T> for T where T: ?Sized,[src]#
impl<T>borrow_mut(&mut self) -> &mutT[src]#
pub fnMutably borrows from an owned value. Read more
From<T> for T[src]#
impl<T>from(t: T) -> T[src]#
pub fnPerforms the conversion.
Into<U> for T where U: From<T>,[src]#
impl<T, U>into(self) -> U[src]#
pub fnPerforms the conversion.
ToOwned for T where T: Clone,[src]#
impl<T>Owned = T#
typeThe resulting type after obtaining ownership.
to_owned(&self) -> T[src]#
pub fnCreates owned data from borrowed data, usually by cloning. Read more
clone_into(&self, target: &mutT)[src]#
pub fn🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
TryFrom<U> for T where U: Into<T>,[src]#
impl<T, U>Error = Infallible#
typeThe type returned in the event of a conversion error.
try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]#
pub fnPerforms the conversion.
TryInto<U> for T where U: TryFrom<T>,[src]#
impl<T, U>Error = <U as TryFrom<T>>::Error#
typeThe type returned in the event of a conversion error.
try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]#
pub fnPerforms the conversion.