diff --git a/common/tool/context_menu.cpp b/common/tool/context_menu.cpp index e59fe5a637..1c0e5c88b1 100644 --- a/common/tool/context_menu.cpp +++ b/common/tool/context_menu.cpp @@ -372,9 +372,8 @@ void CONTEXT_MENU::onMenuEvent( wxMenuEvent& aEvent ) } } - wxASSERT( m_tool ); // without tool & tool manager we cannot handle events - // forward the action/update event to the TOOL_MANAGER + // clients that don't supply a tool will have to check GetSelected() themselves if( evt && m_tool ) { //aEvent.StopPropagation(); diff --git a/common/widgets/grid_text_button_helpers.cpp b/common/widgets/grid_text_button_helpers.cpp index b35fa48cf6..76d59f7055 100644 --- a/common/widgets/grid_text_button_helpers.cpp +++ b/common/widgets/grid_text_button_helpers.cpp @@ -208,8 +208,13 @@ protected: void OnButtonClick() override { - wxString uri = ResolveUriByEnvVars( GetValue() ); - GetAssociatedDocument( m_dlg, uri ); + wxString filename = GetValue(); + + if( !filename.IsEmpty() && filename != wxT( "~" ) ) + { + wxString uri = ResolveUriByEnvVars( GetValue() ); + GetAssociatedDocument( m_dlg, uri ); + } } DIALOG_SHIM* m_dlg; diff --git a/eeschema/generate_alias_info.cpp b/eeschema/generate_alias_info.cpp index c5026d71e0..eea5c51250 100644 --- a/eeschema/generate_alias_info.cpp +++ b/eeschema/generate_alias_info.cpp @@ -170,21 +170,31 @@ protected: { case DATASHEET: { - if( text.IsEmpty() ) - text = m_module->GetDocFileName(); + text = m_module->GetDocFileName(); - wxString datasheetlink = DatasheetLinkFormat; - datasheetlink.Replace( "__HREF__", EscapedHTML( text ) ); + if( text.IsEmpty() || text == wxT( "~" ) ) + { + fieldhtml.Replace( "__VALUE__", text ); + } + else + { + wxString datasheetlink = DatasheetLinkFormat; + datasheetlink.Replace( "__HREF__", EscapedHTML( text ) ); - if( text.Length() > 75 ) - text = text.Left( 72 ) + wxT( "..." ); + if( text.Length() > 75 ) + text = text.Left( 72 ) + wxT( "..." ); - datasheetlink.Replace( "__TEXT__", EscapedHTML( text ) ); + datasheetlink.Replace( "__TEXT__", EscapedHTML( text ) ); - fieldhtml.Replace( "__VALUE__", datasheetlink ); + fieldhtml.Replace( "__VALUE__", datasheetlink ); + } } break; + case VALUE: + // showing the value just repeats the name, so that's not much use... + return wxEmptyString; + default: fieldhtml.Replace( "__VALUE__", EscapedHTML( text ) ); } diff --git a/eeschema/lib_edit_frame.cpp b/eeschema/lib_edit_frame.cpp index 99f240c8ac..82a9eb246a 100644 --- a/eeschema/lib_edit_frame.cpp +++ b/eeschema/lib_edit_frame.cpp @@ -65,7 +65,7 @@ #include #include - +#include int LIB_EDIT_FRAME:: m_unit = 1; int LIB_EDIT_FRAME:: m_convert = 1; @@ -570,18 +570,32 @@ void LIB_EDIT_FRAME::OnViewEntryDoc( wxCommandEvent& event ) if( !part ) return; - wxString fileName; + wxString filename; - // TODO: it would be nice to offer a menu here of aliases.... - LIB_ALIAS* alias = part->GetAlias( part->GetName() ); + if( part->GetAliasCount() > 1 ) + { + CONTEXT_MENU popup; + wxString msg; - fileName = alias->GetDocFileName(); + for( LIB_ALIAS* alias : part->GetAliases() ) + { + msg.Printf( wxT( "%s (%s)" ), alias->GetName(), alias->GetDocFileName() ); + popup.Append( wxID_ANY, msg ); + } - if( !fileName.IsEmpty() ) + PopupMenu( &popup ); + + if( popup.GetSelected() >= 0 ) + filename = part->GetAlias( (unsigned) popup.GetSelected() )->GetDocFileName(); + } + else + filename = part->GetAlias( 0 )->GetDocFileName(); + + if( !filename.IsEmpty() && filename != wxT( "~" ) ) { SEARCH_STACK* lib_search = Prj().SchSearchS(); - GetAssociatedDocument( this, fileName, lib_search ); + GetAssociatedDocument( this, filename, lib_search ); } }