@@ -9,6 +9,7 @@ pub(crate) mod tray;
99use crate :: {
1010 api:: assets:: Assets ,
1111 api:: config:: { Config , WindowUrl } ,
12+ command:: { CommandArg , CommandItem } ,
1213 hooks:: { InvokeHandler , OnPageLoad , PageLoadPayload , SetupHook } ,
1314 manager:: { Args , WindowManager } ,
1415 plugin:: { Plugin , PluginStore } ,
@@ -19,7 +20,7 @@ use crate::{
1920 Dispatch , MenuId , Params , RunEvent , Runtime ,
2021 } ,
2122 sealed:: { ManagerBase , RuntimeOrDispatch } ,
22- Context , Invoke , Manager , StateManager , Window ,
23+ Context , Invoke , InvokeError , Manager , StateManager , Window ,
2324} ;
2425
2526use tauri_utils:: PackageInfo ;
@@ -133,6 +134,13 @@ impl<P: Params> Clone for AppHandle<P> {
133134 }
134135}
135136
137+ impl < ' de , P : Params > CommandArg < ' de , P > for AppHandle < P > {
138+ /// Grabs the [`Window`] from the [`CommandItem`] and returns the associated [`AppHandle`]. This will never fail.
139+ fn from_command ( command : CommandItem < ' de , P > ) -> Result < Self , InvokeError > {
140+ Ok ( command. message . window ( ) . app_handle )
141+ }
142+ }
143+
136144impl < P : Params > AppHandle < P > {
137145 /// Removes the system tray.
138146 #[ cfg( all( windows, feature = "system-tray" ) ) ]
0 commit comments