From 62a5302bc476264928592e14498a042516e30ba8 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 21 May 2019 12:48:37 +0200 Subject: [PATCH] Fix issues created by commit cbb0d74bd54b. This commit redirected too many menuitem IDs to the tool manager. Only some context menu items have to be redirected, not all inside ACTION_EVENT events. This hack is not perfect. It needs a better handling of ACTION_EVENT handling. --- common/tool/action_menu.cpp | 9 ++++++++- eeschema/eeschema_id.h | 31 ++++++++++++++++++------------- include/id.h | 4 ++++ 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/common/tool/action_menu.cpp b/common/tool/action_menu.cpp index c3d92d9865..bc139ecfdb 100644 --- a/common/tool/action_menu.cpp +++ b/common/tool/action_menu.cpp @@ -32,6 +32,7 @@ #include #include #include +#include using namespace std::placeholders; @@ -401,7 +402,13 @@ void ACTION_MENU::OnMenuEvent( wxMenuEvent& aEvent ) #endif // Handling non-action menu entries (e.g. items in clarification list) - if( !evt && ( m_selected < wxID_LOWEST || m_selected > wxID_HIGHEST ) ) + // in some context menus, that have IDs explicitly chosen between + // ID_POPUP_MENU_START and ID_POPUP_MENU_END + if( !evt && ( m_selected < wxID_LOWEST || + ( m_selected >= ID_POPUP_MENU_START && + m_selected <= ID_POPUP_MENU_END ) + ) + ) { menuText = GetLabelText( aEvent.GetId() ); evt = TOOL_EVENT( TC_COMMAND, TA_CONTEXT_MENU_CHOICE, m_selected, AS_GLOBAL, diff --git a/eeschema/eeschema_id.h b/eeschema/eeschema_id.h index cc4aeaa517..843af7c358 100644 --- a/eeschema/eeschema_id.h +++ b/eeschema/eeschema_id.h @@ -94,18 +94,6 @@ enum id_eeschema_frm ID_PLACE_IMAGE_TOOL, ID_DELETE_TOOL, - // Dynamically bound in AddMenusForBus() - ID_POPUP_SCH_UNFOLD_BUS, - ID_POPUP_SCH_UNFOLD_BUS_END = ID_POPUP_SCH_UNFOLD_BUS + 64, - - // Unit select context menus command IDs. - ID_POPUP_SCH_SELECT_UNIT_CMP, - ID_POPUP_SCH_SELECT_UNIT1, - // ... leave room for MAX_UNIT_COUNT_PER_PACKAGE IDs , - // to select one unit among MAX_UNIT_COUNT_PER_PACKAGE in popup menu - ID_POPUP_SCH_SELECT_UNIT_CMP_MAX = ID_POPUP_SCH_SELECT_UNIT1 - + MAX_UNIT_COUNT_PER_PACKAGE, - ID_SCH_MOVE, ID_SCH_DRAG, ID_SCH_UNFOLD_BUS, @@ -180,7 +168,24 @@ enum id_eeschema_frm ID_SIM_ADD_SIGNALS, ID_SIM_SHOW, - ID_END_EESCHEMA_ID_LIST + ID_END_EESCHEMA_ID_LIST, // End of IDs specific to Eeschema + + // These ID are used in context menus, + // and must not clash with any other menu ID inside Kicad + // So used ID inside the reserved popup ID + // + // Dynamically bound in AddMenusForBus(): + ID_POPUP_SCH_UNFOLD_BUS = ID_POPUP_MENU_START, + ID_POPUP_SCH_UNFOLD_BUS_END = ID_POPUP_SCH_UNFOLD_BUS + 128, + + // Unit select context menus command IDs. + ID_POPUP_SCH_SELECT_UNIT_CMP, + ID_POPUP_SCH_SELECT_UNIT1, + // ... leave room for MAX_UNIT_COUNT_PER_PACKAGE IDs , + // to select one unit among MAX_UNIT_COUNT_PER_PACKAGE in popup menu + ID_POPUP_SCH_SELECT_UNIT_CMP_MAX = ID_POPUP_SCH_SELECT_UNIT1 + + MAX_UNIT_COUNT_PER_PACKAGE + }; diff --git a/include/id.h b/include/id.h index 5cc9608390..f3c6a84256 100644 --- a/include/id.h +++ b/include/id.h @@ -289,6 +289,10 @@ enum main_id ID_KICAD_PANEL_PREV_MODEL_START, ID_KICAD_PANEL_PREV_MODEL_END = ID_KICAD_PANEL_PREV_MODEL_START + ROOM_FOR_PANEL_PREV_MODEL, + // Reseve ID for popup menus, when we need to know a menu item is inside a popup menu + ID_POPUP_MENU_START, + ID_POPUP_MENU_END = ID_POPUP_MENU_START + 1000, + ID_END_LIST };