From e68ae91b59bf8a1af0b4841ec1604de5470025d8 Mon Sep 17 00:00:00 2001 From: TellowKrinkle Date: Fri, 28 Mar 2025 21:12:47 -0500 Subject: [PATCH] MacOS: Mark our help menu as the macOS help menu This gives it a nice search box for searching other menus --- common/CocoaTools.h | 2 ++ common/CocoaTools.mm | 5 +++++ pcsx2-qt/MainWindow.cpp | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/common/CocoaTools.h b/common/CocoaTools.h index 1166effc4c..8da50f8a2a 100644 --- a/common/CocoaTools.h +++ b/common/CocoaTools.h @@ -19,6 +19,8 @@ namespace CocoaTools void AddThemeChangeHandler(void* ctx, void(handler)(void* ctx)); /// Remove a handler previously added using AddThemeChangeHandler with the given context void RemoveThemeChangeHandler(void* ctx); + /// Mark an NSMenu as the help menu + void MarkHelpMenu(void* menu); /// Returns the bundle path. std::optional GetBundlePath(); /// Get the bundle path to the actual application without any translocation fun diff --git a/common/CocoaTools.mm b/common/CocoaTools.mm index 71b4c91184..adbe803b80 100644 --- a/common/CocoaTools.mm +++ b/common/CocoaTools.mm @@ -143,6 +143,11 @@ void CocoaTools::RemoveThemeChangeHandler(void* ctx) [s_themeChangeHandler removeCallback:ctx]; } +void CocoaTools::MarkHelpMenu(void* menu) +{ + [NSApp setHelpMenu:(__bridge NSMenu*)menu]; +} + // MARK: - Sound playback bool Common::PlaySoundAsync(const char* path) diff --git a/pcsx2-qt/MainWindow.cpp b/pcsx2-qt/MainWindow.cpp index 80c05d515e..e44a0749b7 100644 --- a/pcsx2-qt/MainWindow.cpp +++ b/pcsx2-qt/MainWindow.cpp @@ -151,6 +151,10 @@ void MainWindow::initialize() ctx->updateTheme(); // Qt won't notice the style change without us touching the palette in some way }); }); + // The cocoa backing isn't initialized yet, delay this until stuff is set up with a `RunOnUIThread` call + QtHost::RunOnUIThread([this]{ + CocoaTools::MarkHelpMenu(m_ui.menuHelp->toNSMenu()); + }); #endif m_ui.setupUi(this); setupAdditionalUi();