Allow textboxes to have no text. (They still have a defined box.)
Fixes https://gitlab.com/kicad/code/kicad/issues/11286
This commit is contained in:
parent
c591e19e9f
commit
0bd3341f0f
|
@ -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() ) );
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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() );
|
||||
|
||||
|
|
Loading…
Reference in New Issue