Skip to content

Commit

Permalink
feat(core): return listener id on Window#on_menu_event (#2045)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Jun 22, 2021
1 parent 9f41e51 commit 030c9c7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions core/tauri/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,16 @@ impl<P: Params> Window<P> {
/// Registers a menu event listener.
#[cfg(feature = "menu")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "menu")))]
pub fn on_menu_event<F: Fn(menu::MenuEvent<P::MenuId>) + Send + 'static>(&self, f: F) {
pub fn on_menu_event<F: Fn(menu::MenuEvent<P::MenuId>) + Send + 'static>(
&self,
f: F,
) -> uuid::Uuid {
let menu_ids = self.manager.menu_ids();
self.window.dispatcher.on_menu_event(move |event| {
f(menu::MenuEvent {
menu_item_id: menu_ids.get(&event.menu_item_id).unwrap().clone(),
})
});
})
}

// Getters
Expand Down

0 comments on commit 030c9c7

Please sign in to comment.