Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Plugins/MacOS/mac_utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ void mac_fix_yosemite_bug();
void mac_begin_server ();
void mac_end_server ();

void mac_save_and_clear_menu ();
void mac_restore_menu ();

#endif // MAC_UTILITIES_H
17 changes: 17 additions & 0 deletions src/Plugins/MacOS/mac_utilities.mm
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,23 @@ unless we remove the duplicates and most plugins fail to start (since they are
}


static NSMenu* savedMainMenu= nil;

void
mac_save_and_clear_menu () {
savedMainMenu= [[NSApp mainMenu] retain];
[NSApp setMainMenu:nil];
}

void
mac_restore_menu () {
if (savedMainMenu) {
[NSApp setMainMenu:savedMainMenu];
[savedMainMenu release];
savedMainMenu= nil;
}
}

static id background_activity= nil;

void
Expand Down
18 changes: 18 additions & 0 deletions src/Plugins/Qt/qt_chooser_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@
#include "mupdf_picture.hpp"
#endif

#include <QApplication>
#include <QByteArray>
#include <QDebug>
#include <QFileDialog>
#include <QString>
#include <QStringList>

#ifdef OS_MACOS
#include "MacOS/mac_utilities.h"
#endif

#include <moebius/data/scheme.hpp>

using moebius::data::scm_quote;
Expand Down Expand Up @@ -344,6 +349,15 @@ qt_chooser_widget_rep::perform_dialog () {
r.moveCenter (pos);
dialog->setGeometry (r);

#ifdef OS_MACOS
// On macOS, QAction shortcuts registered in the menu bar become NSMenuItem
// key equivalents. When a native file dialog is open, these key equivalents
// intercept standard editing shortcuts (Cmd+V, Cmd+C, Cmd+X, Cmd+A) before
// the dialog's text field can handle them. Temporarily removing the native
// menu allows the dialog to process these keys normally.
mac_save_and_clear_menu ();
#endif

QStringList fileNames;
file= "#f";
if (dialog->exec ()) {
Expand Down Expand Up @@ -429,6 +443,10 @@ qt_chooser_widget_rep::perform_dialog () {

delete dialog;

#ifdef OS_MACOS
mac_restore_menu ();
#endif

cmd ();
if (!is_nil (quit)) quit ();
}
Loading