Tweak menubar export
This commit is contained in:
3 files changed
+19
-17
No files matched your search
@@ -15,6 +15,7 @@ mod events;
|
|||||||
mod file_upload;
|
mod file_upload;
|
||||||
mod hooks;
|
mod hooks;
|
||||||
mod ipc;
|
mod ipc;
|
||||||
|
mod menubar;
|
||||||
mod protocol;
|
mod protocol;
|
||||||
mod query;
|
mod query;
|
||||||
mod shortcut;
|
mod shortcut;
|
||||||
@@ -28,10 +29,6 @@ mod collect_assets;
|
|||||||
#[cfg(any(target_os = "ios", target_os = "android"))]
|
#[cfg(any(target_os = "ios", target_os = "android"))]
|
||||||
mod mobile_shortcut;
|
mod mobile_shortcut;
|
||||||
|
|
||||||
// menu bar is only supported on desktop platforms
|
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
|
||||||
mod menubar;
|
|
||||||
|
|
||||||
// The main entrypoint for this crate
|
// The main entrypoint for this crate
|
||||||
pub use launch::*;
|
pub use launch::*;
|
||||||
mod launch;
|
mod launch;
|
||||||
@@ -50,6 +47,5 @@ pub use desktop_context::{
|
|||||||
window, DesktopContext, DesktopService, WryEventHandler, WryEventHandlerId,
|
window, DesktopContext, DesktopService, WryEventHandler, WryEventHandlerId,
|
||||||
};
|
};
|
||||||
pub use hooks::{use_asset_handler, use_global_shortcut, use_window, use_wry_event_handler};
|
pub use hooks::{use_asset_handler, use_global_shortcut, use_window, use_wry_event_handler};
|
||||||
pub use menubar::build_default_menu_bar;
|
|
||||||
pub use shortcut::{ShortcutHandle, ShortcutId, ShortcutRegistryError};
|
pub use shortcut::{ShortcutHandle, ShortcutId, ShortcutRegistryError};
|
||||||
pub use wry::RequestAsyncResponder;
|
pub use wry::RequestAsyncResponder;
|
||||||
@@ -1,14 +1,19 @@
|
|||||||
use muda::{Menu, PredefinedMenuItem, Submenu};
|
|
||||||
use tao::window::Window;
|
use tao::window::Window;
|
||||||
|
|
||||||
pub fn build_menu(window: &Window, default_menu_bar: bool) {
|
pub fn build_menu(window: &Window, default_menu_bar: bool) {
|
||||||
if default_menu_bar {
|
if default_menu_bar {
|
||||||
build_menu_bar(build_default_menu_bar(), window)
|
#[cfg(not(any(target_os = "ios", target_os = "android")))]
|
||||||
|
impl_::build_menu_bar(impl_::build_default_menu_bar(), window)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
#[cfg(not(any(target_os = "ios", target_os = "android")))]
|
||||||
pub fn build_menu_bar(menu: Menu, window: &Window) {
|
mod impl_ {
|
||||||
|
use super::*;
|
||||||
|
use muda::{Menu, PredefinedMenuItem, Submenu};
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
|
pub fn build_menu_bar(menu: Menu, window: &Window) {
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
menu.init_for_hwnd(window);
|
menu.init_for_hwnd(window);
|
||||||
|
|
||||||
@@ -21,14 +26,14 @@ pub fn build_menu_bar(menu: Menu, window: &Window) {
|
|||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
menu.init_for_nsapp();
|
menu.init_for_nsapp();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Builds a standard menu bar depending on the users platform. It may be used as a starting point
|
/// Builds a standard menu bar depending on the users platform. It may be used as a starting point
|
||||||
/// to further customize the menu bar and pass it to a [`WindowBuilder`](tao::window::WindowBuilder).
|
/// to further customize the menu bar and pass it to a [`WindowBuilder`](tao::window::WindowBuilder).
|
||||||
/// > Note: The default menu bar enables macOS shortcuts like cut/copy/paste.
|
/// > Note: The default menu bar enables macOS shortcuts like cut/copy/paste.
|
||||||
/// > The menu bar differs per platform because of constraints introduced
|
/// > The menu bar differs per platform because of constraints introduced
|
||||||
/// > by [`MenuItem`](tao::menu::MenuItem).
|
/// > by [`MenuItem`](tao::menu::MenuItem).
|
||||||
pub fn build_default_menu_bar() -> Menu {
|
pub fn build_default_menu_bar() -> Menu {
|
||||||
let menu = Menu::new();
|
let menu = Menu::new();
|
||||||
|
|
||||||
// since it is uncommon on windows to have an "application menu"
|
// since it is uncommon on windows to have an "application menu"
|
||||||
@@ -66,4 +71,5 @@ pub fn build_default_menu_bar() -> Menu {
|
|||||||
menu.append_items(&[&window_menu, &edit_menu]).unwrap();
|
menu.append_items(&[&window_menu, &edit_menu]).unwrap();
|
||||||
|
|
||||||
menu
|
menu
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use wry::application::event_loop::EventLoopWindowTarget;
|
use tao::event_loop::EventLoopWindowTarget;
|
||||||
|
|
||||||
use dioxus_html::input_data::keyboard_types::Modifiers;
|
use dioxus_html::input_data::keyboard_types::Modifiers;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user