From 13aa5036146442bb97c48c94688439df890d8b5a Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 17 May 2019 15:35:50 +0100 Subject: [PATCH] Hack for wxWidgets failure to open menu on MSW. --- common/tool/conditional_menu.cpp | 12 ++++++++++++ include/tool/conditional_menu.h | 7 +------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/common/tool/conditional_menu.cpp b/common/tool/conditional_menu.cpp index 52fadba05e..4610029f13 100644 --- a/common/tool/conditional_menu.cpp +++ b/common/tool/conditional_menu.cpp @@ -27,6 +27,18 @@ #include +CONDITIONAL_MENU::CONDITIONAL_MENU( bool isContextMenu, TOOL_INTERACTIVE* aTool ) : + m_isContextMenu( isContextMenu ) +{ + m_tool = aTool; + + // wxWidgets 3.0.4 on MSW checks for an empty menu before running the MENU_OPEN + // event. Add a dummy item to ensure that the event is dispatched. Evaluate() + // will clear the menu before evaluating all the items anyway. + Append( wxID_ANY, wxT( "dummy menu for MSW" ) ); +} + + ACTION_MENU* CONDITIONAL_MENU::create() const { CONDITIONAL_MENU* clone = new CONDITIONAL_MENU( m_isContextMenu, m_tool ); diff --git a/include/tool/conditional_menu.h b/include/tool/conditional_menu.h index 9c25889200..f180db7c82 100644 --- a/include/tool/conditional_menu.h +++ b/include/tool/conditional_menu.h @@ -42,12 +42,7 @@ public: ///> Constant to indicate that we do not care about an ENTRY location in the menu. static const int ANY_ORDER = -1; - - CONDITIONAL_MENU( bool isContextMenu, TOOL_INTERACTIVE* aTool ) : - m_isContextMenu( isContextMenu ) - { - m_tool = aTool; - } + CONDITIONAL_MENU( bool isContextMenu, TOOL_INTERACTIVE* aTool ); ACTION_MENU* create() const override;