diff --git a/eeschema/dialogs/dialog_lib_textbox_properties.cpp b/eeschema/dialogs/dialog_lib_textbox_properties.cpp index da5d434c0a..b507dbb72c 100644 --- a/eeschema/dialogs/dialog_lib_textbox_properties.cpp +++ b/eeschema/dialogs/dialog_lib_textbox_properties.cpp @@ -204,20 +204,16 @@ bool DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataFromWindow() wxString text = m_textCtrl->GetValue(); - if( !text.IsEmpty() ) - { #ifdef __WXMAC__ - // On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting - text.Replace( "\r", "\n" ); + // On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting + text.Replace( "\r", "\n" ); +#elif defined( __WINDOWS__ ) + // On Windows, a new line is coded as \r\n. We use only \n in kicad files and in + // drawing routines so strip the \r char. + text.Replace( "\r", "" ); #endif - m_currentText->SetText( text ); - } - else if( !m_currentText->IsNew() ) - { - DisplayError( this, _( "Text can not be empty." ) ); - return false; - } + m_currentText->SetText( text ); if( m_currentText->GetTextWidth() != m_textSize.GetValue() ) m_currentText->SetTextSize( wxSize( m_textSize.GetValue(), m_textSize.GetValue() ) ); diff --git a/eeschema/dialogs/dialog_text_properties.cpp b/eeschema/dialogs/dialog_text_properties.cpp index de8915139a..d3db1ad457 100644 --- a/eeschema/dialogs/dialog_text_properties.cpp +++ b/eeschema/dialogs/dialog_text_properties.cpp @@ -354,17 +354,27 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() // convert any text variable cross-references to their UUIDs text = m_frame->Schematic().ConvertRefsToKIIDs( m_textCtrl->GetValue() ); - if( !text.IsEmpty() ) - { #ifdef __WXMAC__ - // On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting - text.Replace( "\r", "\n" ); + // On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting + text.Replace( "\r", "\n" ); +#elif defined( __WINDOWS__ ) + // On Windows, a new line is coded as \r\n. We use only \n in kicad files and in + // drawing routines so strip the \r char. + text.Replace( "\r", "" ); #endif + if( m_currentItem->Type() == SCH_TEXTBOX_T ) + { + // Textboxes have a defined extent and so are allowed to be empty + m_currentText->SetText( wxEmptyString ); + } + else if( !text.IsEmpty() ) + { m_currentText->SetText( text ); } - else if( !m_currentItem->IsNew() ) + else { + // Other text items do not have defined extents, and so will disappear if empty DisplayError( this, _( "Text can not be empty." ) ); return false; } diff --git a/pcbnew/dialogs/dialog_textbox_properties.cpp b/pcbnew/dialogs/dialog_textbox_properties.cpp index 45bb58f657..06d9175e59 100644 --- a/pcbnew/dialogs/dialog_textbox_properties.cpp +++ b/pcbnew/dialogs/dialog_textbox_properties.cpp @@ -313,23 +313,20 @@ bool DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow() if( !pushCommit ) m_item->SetFlags( IN_EDIT ); - // Set the new text content - if( !m_MultiLineText->GetValue().IsEmpty() ) - { - BOARD* board = m_frame->GetBoard(); - wxString txt = board->ConvertCrossReferencesToKIIDs( m_MultiLineText->GetValue() ); + BOARD* board = m_frame->GetBoard(); + wxString txt = board->ConvertCrossReferencesToKIIDs( m_MultiLineText->GetValue() ); #ifdef __WXMAC__ - // On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting. - // Replace it now. - txt.Replace( "\r", "\n" ); + // On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting. + // Replace it now. + txt.Replace( "\r", "\n" ); #elif defined( __WINDOWS__ ) - // On Windows, a new line is coded as \r\n. We use only \n in kicad files and in - // drawing routines so strip the \r char. - txt.Replace( "\r", "" ); + // On Windows, a new line is coded as \r\n. We use only \n in kicad files and in + // drawing routines so strip the \r char. + txt.Replace( "\r", "" ); #endif - m_edaText->SetText( EscapeString( txt, CTX_QUOTED_STR ) ); - } + + m_edaText->SetText( EscapeString( txt, CTX_QUOTED_STR ) ); m_item->SetLocked( m_cbLocked->GetValue() );