Pass un-pretty-printed bus names through menu help text.

Fixes https://gitlab.com/kicad/code/kicad/issues/7412
This commit is contained in:
Jeff Young 2021-02-10 15:02:28 +00:00
parent 4679682fe9
commit a30ae6a237
3 changed files with 19 additions and 15 deletions

View File

@ -496,19 +496,23 @@ void ACTION_MENU::OnMenuEvent( wxMenuEvent& aEvent )
runEventHandlers( aEvent, evt );
#endif
// Handling non-action menu entries (e.g. items in clarification list)
// in some context menus, that have IDs explicitly chosen between
// ID_POPUP_MENU_START and ID_POPUP_MENU_END
// Note also items in clarification list have an id >= 0 and < wxID_LOWEST
// in fact 0 to n-1 for n items in clarification list)
// id < 0 are automatically created for menuitems created with wxID_ANY
#define ID_CONTEXT_MENU_ID_MAX wxID_LOWEST /* = 100 should be enough and better */
// Handling non-ACTION menu entries. Two ranges of ids are supported:
// between 0 and ID_CONTEXT_MENU_ID_MAX
// between ID_POPUP_MENU_START and ID_POPUP_MENU_END
#define ID_CONTEXT_MENU_ID_MAX wxID_LOWEST /* = 100 should be plenty */
if( !evt &&
( ( m_selected >= 0 && m_selected < ID_CONTEXT_MENU_ID_MAX ) ||
( m_selected >= ID_POPUP_MENU_START && m_selected <= ID_POPUP_MENU_END ) ) )
{
ACTION_MENU* actionMenu = dynamic_cast<ACTION_MENU*>( GetParent() );
if( actionMenu && actionMenu->PassHelpTextToHandler() )
menuText = GetHelpString( aEvent.GetId() );
else
menuText = GetLabelText( aEvent.GetId() );
evt = TOOL_EVENT( TC_COMMAND, TA_CHOICE_MENU_CHOICE, m_selected, AS_GLOBAL,
&menuText );
}

View File

@ -49,7 +49,6 @@
#include <tool/tool_event.h>
#include <trigo.h>
#include <undo_redo_container.h>
#include <connection_graph.h>
#include <eeschema_id.h>
#include <sch_bus_entry.h>
@ -61,10 +60,8 @@
#include <sch_sheet.h>
#include <sch_text.h>
#include <schematic.h>
#include <ee_actions.h>
#include <ee_grid_helper.h>
#include <ee_point_editor.h>
#include <ee_selection.h>
#include <ee_selection_tool.h>
@ -84,6 +81,7 @@ public:
m_showTitle = true;
}
bool PassHelpTextToHandler() override { return true; }
protected:
ACTION_MENU* create() const override
@ -139,19 +137,19 @@ private:
for( const auto& member : connection->Members() )
{
int id = ID_POPUP_SCH_UNFOLD_BUS + ( idx++ );
wxString name = SCH_CONNECTION::PrintBusForUI( member->FullLocalName() );
wxString name = member->FullLocalName();
if( member->Type() == CONNECTION_TYPE::BUS )
{
ACTION_MENU* submenu = new ACTION_MENU( true );
submenu->SetTool( m_tool );
AppendSubMenu( submenu, name );
AppendSubMenu( submenu, SCH_CONNECTION::PrintBusForUI( name ), name );
for( const auto& sub_member : member->Members() )
{
id = ID_POPUP_SCH_UNFOLD_BUS + ( idx++ );
name = SCH_CONNECTION::PrintBusForUI( sub_member->FullLocalName() );
submenu->Append( id, name, wxEmptyString );
name = sub_member->FullLocalName();
submenu->Append( id, SCH_CONNECTION::PrintBusForUI( name ), name );
}
}
else

View File

@ -170,6 +170,8 @@ public:
void OnMenuEvent( wxMenuEvent& aEvent );
void OnIdle( wxIdleEvent& event );
virtual bool PassHelpTextToHandler() { return false; }
static constexpr bool CHECK = true;
protected: