Don't assume a hypertext link is a cross-sheet reference.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20511
This commit is contained in:
Jeff Young 2025-03-30 21:54:52 +01:00
parent 2b0d082df5
commit 582aef0220

View File

@ -1013,31 +1013,39 @@ void SCH_FIELD::DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const
if( IsHypertext() )
{
SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( m_parent );
SCH_SHEET_PATH* sheet = &label->Schematic()->CurrentSheet();
wxMenu menu;
wxString href;
wxString href;
std::vector<std::pair<wxString, wxString>> pages;
label->GetIntersheetRefs( sheet, &pages );
for( int i = 0; i < (int) pages.size(); ++i )
if( m_id == FIELD_T::INTERSHEET_REFS )
{
menu.Append( i + START_ID, wxString::Format( _( "Go to Page %s (%s)" ),
pages[i].first,
pages[i].second ) );
SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( m_parent );
SCH_SHEET_PATH* sheet = &label->Schematic()->CurrentSheet();
wxMenu menu;
std::vector<std::pair<wxString, wxString>> pages;
label->GetIntersheetRefs( sheet, &pages );
for( int i = 0; i < (int) pages.size(); ++i )
{
menu.Append( i + START_ID, wxString::Format( _( "Go to Page %s (%s)" ),
pages[i].first,
pages[i].second ) );
}
menu.AppendSeparator();
menu.Append( 999 + START_ID, _( "Back to Previous Selected Sheet" ) );
int sel = aFrame->GetPopupMenuSelectionFromUser( menu ) - START_ID;
if( sel >= 0 && sel < (int) pages.size() )
href = wxT( "#" ) + pages[ sel ].first;
else if( sel == 999 )
href = SCH_NAVIGATE_TOOL::g_BackLink;
}
else if( IsURL( GetShownText( false ) ) )
{
href = GetShownText( false );
}
menu.AppendSeparator();
menu.Append( 999 + START_ID, _( "Back to Previous Selected Sheet" ) );
int sel = aFrame->GetPopupMenuSelectionFromUser( menu ) - START_ID;
if( sel >= 0 && sel < (int) pages.size() )
href = wxT( "#" ) + pages[ sel ].first;
else if( sel == 999 )
href = SCH_NAVIGATE_TOOL::g_BackLink;
if( !href.IsEmpty() )
{