diff --git a/eeschema/dialogs/dialog_schematic_find.cpp b/eeschema/dialogs/dialog_schematic_find.cpp index 37e57443ea..9fad6f1b6a 100644 --- a/eeschema/dialogs/dialog_schematic_find.cpp +++ b/eeschema/dialogs/dialog_schematic_find.cpp @@ -292,7 +292,7 @@ wxArrayString DIALOG_SCH_FIND::GetFindEntries() const } -void DIALOG_SCH_FIND::SetFindEntries( const wxArrayString& aEntries ) +void DIALOG_SCH_FIND::SetFindEntries( const wxArrayString& aEntries, const wxString& aFindString ) { m_comboFind->Append( aEntries ); @@ -302,7 +302,12 @@ void DIALOG_SCH_FIND::SetFindEntries( const wxArrayString& aEntries ) m_comboFind->Delete( 9 ); } - if( m_comboFind->GetCount() ) + if( !aFindString.IsEmpty() ) + { + m_comboFind->SetValue( aFindString ); + m_comboFind->SelectAll(); + } + else if( m_comboFind->GetCount() ) { m_comboFind->SetSelection( 0 ); m_comboFind->SelectAll(); diff --git a/eeschema/dialogs/dialog_schematic_find.h b/eeschema/dialogs/dialog_schematic_find.h index a438b4f640..1ff6732037 100644 --- a/eeschema/dialogs/dialog_schematic_find.h +++ b/eeschema/dialogs/dialog_schematic_find.h @@ -51,7 +51,7 @@ public: const wxPoint& aPosition = wxDefaultPosition, const wxSize& aSize = wxDefaultSize, int aStyle = 0 ); - void SetFindEntries( const wxArrayString& aEntries ); + void SetFindEntries( const wxArrayString& aEntries, const wxString& aFindString ); wxArrayString GetFindEntries() const; void SetReplaceEntries( const wxArrayString& aEntries ); diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 92ec27e36d..bbda77f4cf 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -963,13 +963,51 @@ void SCH_EDIT_FRAME::UpdateHierarchyNavigator( bool aForceUpdate ) void SCH_EDIT_FRAME::ShowFindReplaceDialog( bool aReplace ) { + wxString findString; + + EE_SELECTION& selection = m_toolManager->GetTool()->GetSelection(); + + if( selection.Size() == 1 ) + { + EDA_ITEM* front = selection.Front(); + + switch( front->Type() ) + { + case SCH_SYMBOL_T: + findString = static_cast( front )->GetValue( &GetCurrentSheet(), true ); + break; + + case SCH_FIELD_T: + findString = static_cast( front )->GetShownText(); + break; + + case SCH_LABEL_T: + case SCH_GLOBAL_LABEL_T: + case SCH_HIER_LABEL_T: + case SCH_SHEET_PIN_T: + findString = static_cast( front )->GetShownText(); + break; + + case SCH_TEXT_T: + findString = static_cast( front )->GetShownText(); + + if( findString.Contains( wxT( "\n" ) ) ) + findString = findString.Before( '\n' ); + + break; + + default: + break; + } + } + if( m_findReplaceDialog ) m_findReplaceDialog->Destroy(); m_findReplaceDialog= new DIALOG_SCH_FIND( this, m_findReplaceData, wxDefaultPosition, wxDefaultSize, aReplace ? wxFR_REPLACEDIALOG : 0 ); - m_findReplaceDialog->SetFindEntries( m_findStringHistoryList ); + m_findReplaceDialog->SetFindEntries( m_findStringHistoryList, findString ); m_findReplaceDialog->SetReplaceEntries( m_replaceStringHistoryList ); m_findReplaceDialog->Show( true ); }