Minor library identifier validator change.

Use the wxTextValidator style flag to allow the user to clear the library
identifier string.  Use wxTextValidator::SetStyle( wxFILTER_EMPTY ) to
prevent empty library identifier strings which is the current behavior.

(cherry picked from commit 9f9e87f11f)
This commit is contained in:
Wayne Stambaugh 2019-06-18 11:18:09 -04:00
parent 909a25c147
commit 43579f4c02
2 changed files with 9 additions and 2 deletions

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2004-2019 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2018 CERN
*
@ -291,6 +291,10 @@ bool LIB_ID_VALIDATOR::Validate( wxWindow *aParent )
wxString val( text->GetValue() );
wxString tmp = val.Clone(); // For trailing and leading white space tests.
// Allow empty string if empty filter not set to allow clearing the LIB_ID.
if( !(GetStyle() & wxFILTER_EMPTY) && val.IsEmpty() )
return true;
if( tmp.Trim() != val ) // Trailing white space.
{
msg = _( "Entry contains trailing white space." );

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2004-2019 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2018 CERN
*
@ -166,6 +166,9 @@ protected:
/**
* Custom validator that verifies that a string defines a valid #LIB_ID.
*
* The default validation allows empty #LIB_ID strings to allow the #LIB_ID to be cleared.
* Use SetStyle( wxFILTER_EMPTY ) to force a valid #LIB_ID string.
*/
class LIB_ID_VALIDATOR : public wxTextValidator
{