Fix issues created by commit cbb0d74bd5.

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.
This commit is contained in:
jean-pierre charras 2019-05-21 12:48:37 +02:00
parent cbb0d74bd5
commit 62a5302bc4
3 changed files with 30 additions and 14 deletions

View File

@ -32,6 +32,7 @@
#include <tool/action_menu.h>
#include <wx/log.h>
#include <pgm_base.h>
#include <id.h>
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,

View File

@ -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
};

View File

@ -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
};