From 08bc73e27decd7fa5b8b2a6c3346a6793e8a29aa Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Wed, 22 Dec 2021 16:05:46 +0100 Subject: [PATCH] Merge pull request #7148 from AvaloniaUI/fixes/allow-to-disable-menu allow disabling of native menu export. --- src/Avalonia.Native/AvaloniaNativeMenuExporter.cs | 7 +++++++ src/Avalonia.Native/AvaloniaNativePlatformExtensions.cs | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/src/Avalonia.Native/AvaloniaNativeMenuExporter.cs b/src/Avalonia.Native/AvaloniaNativeMenuExporter.cs index 280e52d9be..84ed3fc5ed 100644 --- a/src/Avalonia.Native/AvaloniaNativeMenuExporter.cs +++ b/src/Avalonia.Native/AvaloniaNativeMenuExporter.cs @@ -144,6 +144,13 @@ namespace Avalonia.Native private void DoLayoutReset(bool forceUpdate = false) { + var macOpts = AvaloniaLocator.Current.GetService(); + + if (macOpts != null && macOpts.DisableNativeMenus) + { + return; + } + if (_resetQueued || forceUpdate) { _resetQueued = false; diff --git a/src/Avalonia.Native/AvaloniaNativePlatformExtensions.cs b/src/Avalonia.Native/AvaloniaNativePlatformExtensions.cs index eef765e7ec..10619d675b 100644 --- a/src/Avalonia.Native/AvaloniaNativePlatformExtensions.cs +++ b/src/Avalonia.Native/AvaloniaNativePlatformExtensions.cs @@ -73,5 +73,10 @@ namespace Avalonia /// You can prevent Avalonia from adding those items to the OSX Application Menu with this property. The default value is false. /// public bool DisableDefaultApplicationMenuItems { get; set; } + + /// + /// Gets or sets a value indicating whether the native macOS menu bar will be enabled for the application. + /// + public bool DisableNativeMenus { get; set; } } }