Skip to content

Commit acb8892

Browse files
authored
fix(core): export MenuHandle and MenuEvent (#2148)
1 parent 2e2dc7c commit acb8892

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

.changes/menu-export.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": patch
3+
---
4+
5+
Export `MenuHandle` and `MenuEvent` types on `tauri::window`.

core/tauri/src/window.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
#[cfg_attr(doc_cfg, doc(cfg(feature = "menu")))]
77
pub(crate) mod menu;
88

9+
#[cfg(feature = "menu")]
10+
#[cfg_attr(doc_cfg, doc(cfg(feature = "menu")))]
11+
pub use menu::{MenuEvent, MenuHandle};
12+
913
use crate::{
1014
api::config::WindowUrl,
1115
app::AppHandle,
@@ -307,13 +311,10 @@ impl<P: Params> Window<P> {
307311
/// Registers a menu event listener.
308312
#[cfg(feature = "menu")]
309313
#[cfg_attr(doc_cfg, doc(cfg(feature = "menu")))]
310-
pub fn on_menu_event<F: Fn(menu::MenuEvent<P::MenuId>) + Send + 'static>(
311-
&self,
312-
f: F,
313-
) -> uuid::Uuid {
314+
pub fn on_menu_event<F: Fn(MenuEvent<P::MenuId>) + Send + 'static>(&self, f: F) -> uuid::Uuid {
314315
let menu_ids = self.manager.menu_ids();
315316
self.window.dispatcher.on_menu_event(move |event| {
316-
f(menu::MenuEvent {
317+
f(MenuEvent {
317318
menu_item_id: menu_ids.get(&event.menu_item_id).unwrap().clone(),
318319
})
319320
})
@@ -323,8 +324,8 @@ impl<P: Params> Window<P> {
323324

324325
/// Gets a handle to the window menu.
325326
#[cfg(feature = "menu")]
326-
pub fn menu_handle(&self) -> menu::MenuHandle<P> {
327-
menu::MenuHandle {
327+
pub fn menu_handle(&self) -> MenuHandle<P> {
328+
MenuHandle {
328329
ids: self.manager.menu_ids(),
329330
dispatcher: self.dispatcher(),
330331
}

core/tauri/src/window/menu.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ impl<P: Params> Clone for MenuItemHandle<P> {
5959
}
6060

6161
impl<P: Params> MenuHandle<P> {
62+
/// Gets a handle to the menu item that has the specified `id`.
6263
pub fn get_item(&self, id: &P::MenuId) -> MenuItemHandle<P> {
6364
for (raw, item_id) in self.ids.iter() {
6465
if item_id == id {

0 commit comments

Comments
 (0)