diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 8aa12b2069..ea71f92ff3 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -195,15 +195,30 @@ wxString SCH_FIELD::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraT return symbol->ResolveTextVar( aPath, token, aDepth + 1 ); }; + std::function schematicResolver = + [&]( wxString* token ) -> bool + { + if( SCHEMATIC* schematic = Schematic() ) + return schematic->ResolveTextVar( aPath, token, aDepth + 1 ); + + return false; + }; + std::function sheetResolver = [&]( wxString* token ) -> bool { SCH_SHEET* sheet = static_cast( m_parent ); + SCHEMATIC* schematic = Schematic(); SCH_SHEET_PATH path = *aPath; path.push_back( sheet ); - return sheet->ResolveTextVar( &path, token, aDepth + 1 ); + bool retval = sheet->ResolveTextVar( &path, token, aDepth + 1 ); + + if( schematic ) + retval |= schematic->ResolveTextVar( &path, token, aDepth + 1 ); + + return retval; }; std::function labelResolver = @@ -222,7 +237,8 @@ wxString SCH_FIELD::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraT { text = wxS( "" ); } - else if( HasTextVars() ) + + for( int ii = 0; ii < 10 && text.Contains( wxT( "${" ) ); ++ii ) { if( aDepth < 10 ) { @@ -233,7 +249,10 @@ wxString SCH_FIELD::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraT else if( m_parent && m_parent->IsType( { SCH_LABEL_LOCATE_ANY_T } ) ) text = ExpandTextVars( text, &labelResolver ); else if( Schematic() ) + { text = ExpandTextVars( text, &Schematic()->Prj() ); + text = ExpandTextVars( text, &schematicResolver ); + } } }