@@ -63,7 +63,7 @@ pub(crate) type GlobalMenuEventListener<T> = Box<dyn Fn(&T, crate::menu::MenuEve
6363#[ cfg( all( desktop, feature = "tray-icon" ) ) ]
6464pub ( crate ) type GlobalTrayIconEventListener < T > =
6565 Box < dyn Fn ( & T , crate :: tray:: TrayIconEvent ) + Send + Sync > ;
66- pub ( crate ) type GlobalWindowEventListener < R > = Box < dyn Fn ( GlobalWindowEvent < R > ) + Send + Sync > ;
66+ pub ( crate ) type GlobalWindowEventListener < R > = Box < dyn Fn ( & Window < R > , & WindowEvent ) + Send + Sync > ;
6767/// A closure that is run when the Tauri application is setting up.
6868pub type SetupHook < R > =
6969 Box < dyn FnOnce ( & mut App < R > ) -> Result < ( ) , Box < dyn std:: error:: Error > > + Send > ;
@@ -219,26 +219,6 @@ impl From<EventLoopMessage> for RunEvent {
219219 }
220220}
221221
222- /// A window event that was triggered on the specified window.
223- #[ default_runtime( crate :: Wry , wry) ]
224- #[ derive( Debug ) ]
225- pub struct GlobalWindowEvent < R : Runtime > {
226- pub ( crate ) event : WindowEvent ,
227- pub ( crate ) window : Window < R > ,
228- }
229-
230- impl < R : Runtime > GlobalWindowEvent < R > {
231- /// The event payload.
232- pub fn event ( & self ) -> & WindowEvent {
233- & self . event
234- }
235-
236- /// The window that the event belongs to.
237- pub fn window ( & self ) -> & Window < R > {
238- & self . window
239- }
240- }
241-
242222/// The asset resolver is a helper to access the [`tauri_utils::assets::Assets`] interface.
243223#[ derive( Debug , Clone ) ]
244224pub struct AssetResolver < R : Runtime > {
@@ -1304,18 +1284,18 @@ impl<R: Runtime> Builder<R> {
13041284 /// # Examples
13051285 /// ```
13061286 /// tauri::Builder::default()
1307- /// .on_window_event(|event| match event.event() {
1287+ /// .on_window_event(|window, event| match event {
13081288 /// tauri::WindowEvent::Focused(focused) => {
13091289 /// // hide window whenever it loses focus
13101290 /// if !focused {
1311- /// event. window() .hide().unwrap();
1291+ /// window.hide().unwrap();
13121292 /// }
13131293 /// }
13141294 /// _ => {}
13151295 /// });
13161296 /// ```
13171297 #[ must_use]
1318- pub fn on_window_event < F : Fn ( GlobalWindowEvent < R > ) + Send + Sync + ' static > (
1298+ pub fn on_window_event < F : Fn ( & Window < R > , & WindowEvent ) + Send + Sync + ' static > (
13191299 mut self ,
13201300 handler : F ,
13211301 ) -> Self {
0 commit comments