From 6ac54896fab32e2a6e0ac651a8ea3c82acd4cc1b Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Mon, 14 Jan 2019 16:48:23 +0100 Subject: [PATCH] Mac: Fix close events on close by command-Q --- src/slic3r/GUI/MainFrame.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 8a19ccee94..2a60039869 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -428,17 +428,25 @@ void MainFrame::init_menubar() // menubar // assign menubar to frame after appending items, otherwise special items // will not be handled correctly - { - auto menubar = new wxMenuBar(); - menubar->Append(fileMenu, L("&File")); - if (editMenu) menubar->Append(editMenu, L("&Edit")); - menubar->Append(windowMenu, L("&Window")); - if (viewMenu) menubar->Append(viewMenu, L("&View")); - // Add additional menus from C++ - wxGetApp().add_config_menu(menubar); - menubar->Append(helpMenu, L("&Help")); - SetMenuBar(menubar); + auto menubar = new wxMenuBar(); + menubar->Append(fileMenu, L("&File")); + if (editMenu) menubar->Append(editMenu, L("&Edit")); + menubar->Append(windowMenu, L("&Window")); + if (viewMenu) menubar->Append(viewMenu, L("&View")); + // Add additional menus from C++ + wxGetApp().add_config_menu(menubar); + menubar->Append(helpMenu, L("&Help")); + SetMenuBar(menubar); + +#ifdef __APPLE__ + // This fixes a bug (?) on Mac OS where the quit command doesn't emit window close events + wxMenu *apple_menu = menubar->OSXGetAppleMenu(); + if (apple_menu != nullptr) { + apple_menu->Bind(wxEVT_MENU, [this](wxCommandEvent &) { + Close(); + }, wxID_EXIT); } +#endif } // To perform the "Quck Slice", "Quick Slice and Save As", "Repeat last Quick Slice" and "Slice to SVG".