pub struct App<R: Runtime = Wry> { /* private fields */ }
Expand description
The instance of the currently running application.
This type implements Manager
which allows for manipulation of global application items.
Implementations§
source§impl App<Wry>
impl App<Wry>
APIs specific to the wry runtime.
sourcepub fn wry_plugin<P: PluginBuilder<EventLoopMessage> + Send + 'static>(
&mut self,
plugin: P
)where
<P as PluginBuilder<EventLoopMessage>>::Plugin: Send,
pub fn wry_plugin<P: PluginBuilder<EventLoopMessage> + Send + 'static>( &mut self, plugin: P )where <P as PluginBuilder<EventLoopMessage>>::Plugin: Send,
Adds a tauri_runtime_wry::Plugin
using its tauri_runtime_wry::PluginBuilder
.
Stability
This API is unstable.
source§impl<R: Runtime> App<R>
impl<R: Runtime> App<R>
sourcepub fn config(&self) -> &Config
pub fn config(&self) -> &Config
Gets the app’s configuration, defined on the tauri.conf.json
file.
sourcepub fn package_info(&self) -> &PackageInfo
pub fn package_info(&self) -> &PackageInfo
Gets the app’s package information.
sourcepub fn asset_resolver(&self) -> AssetResolver<R>
pub fn asset_resolver(&self) -> AssetResolver<R>
The application’s asset resolver.
sourcepub fn primary_monitor(&self) -> Result<Option<Monitor>>
pub fn primary_monitor(&self) -> Result<Option<Monitor>>
Returns the primary monitor of the system.
Returns None if it can’t identify any monitor as a primary one.
sourcepub fn available_monitors(&self) -> Result<Vec<Monitor>>
pub fn available_monitors(&self) -> Result<Vec<Monitor>>
Returns the list of all the monitors available on the system.
sourcepub fn default_window_icon(&self) -> Option<&Icon>
pub fn default_window_icon(&self) -> Option<&Icon>
Returns the default window icon.
sourcepub fn cleanup_before_exit(&self)
pub fn cleanup_before_exit(&self)
Runs necessary cleanup tasks before exiting the process. You should always exit the tauri app immediately after this function returns and not use any tauri-related APIs.
source§impl<R: Runtime> App<R>
impl<R: Runtime> App<R>
sourcepub fn run_on_main_thread<F: FnOnce() + Send + 'static>(
&self,
f: F
) -> Result<()>
pub fn run_on_main_thread<F: FnOnce() + Send + 'static>( &self, f: F ) -> Result<()>
Runs the given closure on the main thread.
sourcepub fn set_device_event_filter(&mut self, filter: DeviceEventFilter)
pub fn set_device_event_filter(&mut self, filter: DeviceEventFilter)
Change the device event filter mode.
Since the DeviceEvent capture can lead to high CPU usage for unfocused windows, tao
will ignore them by default for unfocused windows on Windows. This method allows changing
the filter to explicitly capture them again.
Platform-specific
- ** Linux / macOS / iOS / Android**: Unsupported.
Examples
let mut app = tauri::Builder::default()
// on an actual app, remove the string argument
.build(tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json"))
.expect("error while building tauri application");
app.set_device_event_filter(tauri::DeviceEventFilter::Always);
app.run(|_app_handle, _event| {});
sourcepub fn run<F: FnMut(&AppHandle<R>, RunEvent) + 'static>(self, callback: F)
pub fn run<F: FnMut(&AppHandle<R>, RunEvent) + 'static>(self, callback: F)
Runs the application.
Examples
let app = tauri::Builder::default()
// on an actual app, remove the string argument
.build(tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json"))
.expect("error while building tauri application");
app.run(|_app_handle, event| match event {
tauri::RunEvent::ExitRequested { api, .. } => {
api.prevent_exit();
}
_ => {}
});
Trait Implementations§
source§impl<R: Runtime> HasRawDisplayHandle for App<R>
impl<R: Runtime> HasRawDisplayHandle for App<R>
fn raw_display_handle(&self) -> RawDisplayHandle
source§impl<R: Runtime> Manager<R> for App<R>
impl<R: Runtime> Manager<R> for App<R>
source§fn app_handle(&self) -> &AppHandle<R>
fn app_handle(&self) -> &AppHandle<R>
source§fn package_info(&self) -> &PackageInfo
fn package_info(&self) -> &PackageInfo
PackageInfo
the manager was created with.source§fn listen_global<F>(&self, event: impl Into<String>, handler: F) -> EventIdwhere
F: Fn(Event) + Send + 'static,
fn listen_global<F>(&self, event: impl Into<String>, handler: F) -> EventIdwhere F: Fn(Event) + Send + 'static,
source§fn once_global<F>(&self, event: impl Into<String>, handler: F)where
F: FnOnce(Event) + Send + 'static,
fn once_global<F>(&self, event: impl Into<String>, handler: F)where F: FnOnce(Event) + Send + 'static,
source§fn emit<S: Serialize + Clone>(&self, event: &str, payload: S) -> Result<()>
fn emit<S: Serialize + Clone>(&self, event: &str, payload: S) -> Result<()>
source§fn emit_to<S: Serialize + Clone>(
&self,
label: &str,
event: &str,
payload: S
) -> Result<()>
fn emit_to<S: Serialize + Clone>( &self, label: &str, event: &str, payload: S ) -> Result<()>
source§fn emit_filter<S, F>(&self, event: &str, payload: S, filter: F) -> Result<()>where
S: Serialize + Clone,
F: Fn(&Window<R>) -> bool,
fn emit_filter<S, F>(&self, event: &str, payload: S, filter: F) -> Result<()>where S: Serialize + Clone, F: Fn(&Window<R>) -> bool,
source§fn get_window(&self, label: &str) -> Option<Window<R>>
fn get_window(&self, label: &str) -> Option<Window<R>>
source§fn get_focused_window(&self) -> Option<Window<R>>
fn get_focused_window(&self) -> Option<Window<R>>
None
if there is not any focused window.source§fn manage<T>(&self, state: T) -> boolwhere
T: Send + Sync + 'static,
fn manage<T>(&self, state: T) -> boolwhere T: Send + Sync + 'static,
state
to the state managed by the application. Read moresource§fn state<T>(&self) -> State<'_, T>where
T: Send + Sync + 'static,
fn state<T>(&self) -> State<'_, T>where T: Send + Sync + 'static,
T
. Read moresource§fn try_state<T>(&self) -> Option<State<'_, T>>where
T: Send + Sync + 'static,
fn try_state<T>(&self) -> Option<State<'_, T>>where T: Send + Sync + 'static,
T
. Read more