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();
|
wxString text = m_textCtrl->GetValue();
|
||||||
|
|
||||||
if( !text.IsEmpty() )
|
|
||||||
{
|
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
// On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting
|
// On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting
|
||||||
text.Replace( "\r", "\n" );
|
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
|
#endif
|
||||||
|
|
||||||
m_currentText->SetText( text );
|
m_currentText->SetText( text );
|
||||||
}
|
|
||||||
else if( !m_currentText->IsNew() )
|
|
||||||
{
|
|
||||||
DisplayError( this, _( "Text can not be empty." ) );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( m_currentText->GetTextWidth() != m_textSize.GetValue() )
|
if( m_currentText->GetTextWidth() != m_textSize.GetValue() )
|
||||||
m_currentText->SetTextSize( wxSize( m_textSize.GetValue(), 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
|
// convert any text variable cross-references to their UUIDs
|
||||||
text = m_frame->Schematic().ConvertRefsToKIIDs( m_textCtrl->GetValue() );
|
text = m_frame->Schematic().ConvertRefsToKIIDs( m_textCtrl->GetValue() );
|
||||||
|
|
||||||
if( !text.IsEmpty() )
|
|
||||||
{
|
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
// On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting
|
// On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting
|
||||||
text.Replace( "\r", "\n" );
|
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
|
#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 );
|
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." ) );
|
DisplayError( this, _( "Text can not be empty." ) );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -313,23 +313,20 @@ bool DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow()
|
||||||
if( !pushCommit )
|
if( !pushCommit )
|
||||||
m_item->SetFlags( IN_EDIT );
|
m_item->SetFlags( IN_EDIT );
|
||||||
|
|
||||||
// Set the new text content
|
BOARD* board = m_frame->GetBoard();
|
||||||
if( !m_MultiLineText->GetValue().IsEmpty() )
|
wxString txt = board->ConvertCrossReferencesToKIIDs( m_MultiLineText->GetValue() );
|
||||||
{
|
|
||||||
BOARD* board = m_frame->GetBoard();
|
|
||||||
wxString txt = board->ConvertCrossReferencesToKIIDs( m_MultiLineText->GetValue() );
|
|
||||||
|
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
// On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting.
|
// On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting.
|
||||||
// Replace it now.
|
// Replace it now.
|
||||||
txt.Replace( "\r", "\n" );
|
txt.Replace( "\r", "\n" );
|
||||||
#elif defined( __WINDOWS__ )
|
#elif defined( __WINDOWS__ )
|
||||||
// On Windows, a new line is coded as \r\n. We use only \n in kicad files and in
|
// 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.
|
// drawing routines so strip the \r char.
|
||||||
txt.Replace( "\r", "" );
|
txt.Replace( "\r", "" );
|
||||||
#endif
|
#endif
|
||||||
m_edaText->SetText( EscapeString( txt, CTX_QUOTED_STR ) );
|
|
||||||
}
|
m_edaText->SetText( EscapeString( txt, CTX_QUOTED_STR ) );
|
||||||
|
|
||||||
m_item->SetLocked( m_cbLocked->GetValue() );
|
m_item->SetLocked( m_cbLocked->GetValue() );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue