Skip to content

Commit

Permalink
Extract macOS application menu initialization to a dedicated function
Browse files Browse the repository at this point in the history
  • Loading branch information
iammattcoleman committed Jun 10, 2023
1 parent 30d5993 commit a2a50f2
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/slic3r/GUI/MainFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,18 @@ static void append_about_menu_item(wxMenu* target_menu)
[](wxCommandEvent&) { Slic3r::GUI::about(); });
}

#ifdef __APPLE__
static void init_macos_application_menu(wxMenuBar* menu_bar, MainFrame* main_frame)
{
wxMenu* apple_menu = menu_bar->OSXGetAppleMenu();
if (apple_menu != nullptr) {
// This fixes a bug on macOS where the quit command doesn't emit window close events.
// wx bug: https://trac.wxwidgets.org/ticket/18328
apple_menu->Bind(wxEVT_MENU, [main_frame](wxCommandEvent&) { main_frame->Close(); }, wxID_EXIT);
}
}
#endif // __APPLE__

static wxMenu* generate_help_menu()
{
wxMenu* helpMenu = new wxMenu();
Expand Down Expand Up @@ -1569,14 +1581,7 @@ void MainFrame::init_menubar_as_editor()
#endif

#ifdef __APPLE__
// This fixes a bug on Mac OS where the quit command doesn't emit window close events
// wx bug: https://trac.wxwidgets.org/ticket/18328
wxMenu* apple_menu = m_menubar->OSXGetAppleMenu();
if (apple_menu != nullptr) {
apple_menu->Bind(wxEVT_MENU, [this](wxCommandEvent &) {
Close();
}, wxID_EXIT);
}
init_macos_application_menu(m_menubar, this);
#endif // __APPLE__

if (plater()->printer_technology() == ptSLA)
Expand Down Expand Up @@ -1661,14 +1666,7 @@ void MainFrame::init_menubar_as_gcodeviewer()
SetMenuBar(m_menubar);

#ifdef __APPLE__
// This fixes a bug on Mac OS where the quit command doesn't emit window close events
// wx bug: https://trac.wxwidgets.org/ticket/18328
wxMenu* apple_menu = m_menubar->OSXGetAppleMenu();
if (apple_menu != nullptr) {
apple_menu->Bind(wxEVT_MENU, [this](wxCommandEvent&) {
Close();
}, wxID_EXIT);
}
init_macos_application_menu(m_menubar, this);
#endif // __APPLE__
}

Expand Down

0 comments on commit a2a50f2

Please sign in to comment.