Просмотр исходного кода

fix (desktop): hide menu when window decorations are disabled (#2613)

* fix: hide menu when window decorations are disabled

* chore: clearer doc description
Andrew Scott 11 месяцев назад
Родитель
Сommit
156144e8f5
1 измененных файлов с 13 добавлено и 2 удалено
  1. 13 2
      packages/desktop/src/config.rs

+ 13 - 2
packages/desktop/src/config.rs

@@ -107,6 +107,13 @@ impl Config {
         // gots to do a swap because the window builder only takes itself as muy self
         // I wish more people knew about returning &mut Self
         self.window = window;
+        if self.window.window.decorations {
+            if self.menu.is_none() {
+                self.menu = Some(default_menu_bar());
+            }
+        } else {
+            self.menu = None;
+        }
         self
     }
 
@@ -203,12 +210,16 @@ impl Config {
 
     /// Sets the menu the window will use. This will override the default menu bar.
     ///
-    /// > Note: A default menu bar will be enabled unless the menu is overridden or set to `None`.
+    /// > Note: Menu will be hidden if
+    /// [`with_decorations`](tao::window::WindowBuilder::with_decorations)
+    /// is set to false and passed into [`with_window`](Config::with_window)
     #[allow(unused)]
     pub fn with_menu(mut self, menu: impl Into<Option<DioxusMenu>>) -> Self {
         #[cfg(not(any(target_os = "ios", target_os = "android")))]
         {
-            self.menu = menu.into();
+            if self.window.window.decorations {
+                self.menu = menu.into();
+            }
         }
         self
     }