DIALOG_ENV_VAR_CONFIG: allows using lowercase chars when typing an env var name. these lowercase chars are converted to uppercase on the fly.

Previously, lowercase chars were not accepted, and nothing was displayed when trying to type a name in lowercase chars.
This commit is contained in:
jean-pierre charras 2018-04-10 20:17:21 +02:00
parent 9ea360f168
commit 4f3b77347a
5 changed files with 34 additions and 10 deletions

View File

@ -65,6 +65,11 @@ public:
protected: protected:
void OnSelectPath( wxCommandEvent& event ) override; void OnSelectPath( wxCommandEvent& event ) override;
void onHelpClick( wxCommandEvent& event ) override; void onHelpClick( wxCommandEvent& event ) override;
// Currently, only upper case variable names are acepted. onVarNameChange
// changes on the fly any lower case char by the corresponding upper case
void onVarNameChange( wxCommandEvent& event ) override;
bool TransferDataFromWindow() override; bool TransferDataFromWindow() override;
}; };
@ -427,6 +432,20 @@ void DIALOG_ENV_VAR_SINGLE::OnSelectPath( wxCommandEvent& event )
} }
void DIALOG_ENV_VAR_SINGLE::onVarNameChange( wxCommandEvent& event )
{
wxString upper_var = m_envVarName->GetValue().Upper();
if( upper_var != m_envVarName->GetValue() )
{
int pos = m_envVarName->GetInsertionPoint();
m_envVarName->ChangeValue( upper_var );
m_envVarName->SetInsertionPoint( pos );
}
}
bool DIALOG_ENV_VAR_SINGLE::TransferDataFromWindow() bool DIALOG_ENV_VAR_SINGLE::TransferDataFromWindow()
{ {
// The user pressed the OK button, test data validity // The user pressed the OK button, test data validity

View File

@ -1,8 +1,8 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 22 2017) // C++ code generated with wxFormBuilder (version Aug 4 2017)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#include "dialog_env_var_config_base.h" #include "dialog_env_var_config_base.h"
@ -61,7 +61,7 @@ DIALOG_ENV_VAR_CONFIG_BASE::DIALOG_ENV_VAR_CONFIG_BASE( wxWindow* parent, wxWind
m_sdbSizer->AddButton( m_sdbSizerHelp ); m_sdbSizer->AddButton( m_sdbSizerHelp );
m_sdbSizer->Realize(); m_sdbSizer->Realize();
mainSizer->Add( m_sdbSizer, 0, wxBOTTOM|wxEXPAND, 5 ); mainSizer->Add( m_sdbSizer, 0, wxBOTTOM|wxALIGN_RIGHT, 5 );
this->SetSizer( mainSizer ); this->SetSizer( mainSizer );
@ -142,7 +142,7 @@ DIALOG_ENV_VAR_SINGLE_BASE::DIALOG_ENV_VAR_SINGLE_BASE( wxWindow* parent, wxWind
m_sdbSizer2->AddButton( m_sdbSizer2Cancel ); m_sdbSizer2->AddButton( m_sdbSizer2Cancel );
m_sdbSizer2->Realize(); m_sdbSizer2->Realize();
bSizerMain->Add( m_sdbSizer2, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); bSizerMain->Add( m_sdbSizer2, 0, wxBOTTOM|wxLEFT|wxRIGHT|wxALIGN_RIGHT, 5 );
this->SetSizer( bSizerMain ); this->SetSizer( bSizerMain );
@ -152,6 +152,7 @@ DIALOG_ENV_VAR_SINGLE_BASE::DIALOG_ENV_VAR_SINGLE_BASE( wxWindow* parent, wxWind
this->Centre( wxBOTH ); this->Centre( wxBOTH );
// Connect Events // Connect Events
m_envVarName->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_ENV_VAR_SINGLE_BASE::onVarNameChange ), NULL, this );
m_buttonHelp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_SINGLE_BASE::onHelpClick ), NULL, this ); m_buttonHelp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_SINGLE_BASE::onHelpClick ), NULL, this );
m_selectPathButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_SINGLE_BASE::OnSelectPath ), NULL, this ); m_selectPathButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_SINGLE_BASE::OnSelectPath ), NULL, this );
} }
@ -159,6 +160,7 @@ DIALOG_ENV_VAR_SINGLE_BASE::DIALOG_ENV_VAR_SINGLE_BASE( wxWindow* parent, wxWind
DIALOG_ENV_VAR_SINGLE_BASE::~DIALOG_ENV_VAR_SINGLE_BASE() DIALOG_ENV_VAR_SINGLE_BASE::~DIALOG_ENV_VAR_SINGLE_BASE()
{ {
// Disconnect Events // Disconnect Events
m_envVarName->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_ENV_VAR_SINGLE_BASE::onVarNameChange ), NULL, this );
m_buttonHelp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_SINGLE_BASE::onHelpClick ), NULL, this ); m_buttonHelp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_SINGLE_BASE::onHelpClick ), NULL, this );
m_selectPathButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_SINGLE_BASE::OnSelectPath ), NULL, this ); m_selectPathButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_ENV_VAR_SINGLE_BASE::OnSelectPath ), NULL, this );

View File

@ -577,7 +577,7 @@
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxBOTTOM|wxEXPAND</property> <property name="flag">wxBOTTOM|wxALIGN_RIGHT</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxStdDialogButtonSizer" expanded="1"> <object class="wxStdDialogButtonSizer" expanded="1">
<property name="Apply">0</property> <property name="Apply">0</property>
@ -853,7 +853,7 @@
<event name="OnRightUp"></event> <event name="OnRightUp"></event>
<event name="OnSetFocus"></event> <event name="OnSetFocus"></event>
<event name="OnSize"></event> <event name="OnSize"></event>
<event name="OnText"></event> <event name="OnText">onVarNameChange</event>
<event name="OnTextEnter"></event> <event name="OnTextEnter"></event>
<event name="OnTextMaxLen"></event> <event name="OnTextMaxLen"></event>
<event name="OnTextURL"></event> <event name="OnTextURL"></event>
@ -1305,7 +1305,7 @@
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT</property> <property name="flag">wxBOTTOM|wxLEFT|wxRIGHT|wxALIGN_RIGHT</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxStdDialogButtonSizer" expanded="1"> <object class="wxStdDialogButtonSizer" expanded="1">
<property name="Apply">0</property> <property name="Apply">0</property>

View File

@ -1,8 +1,8 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 22 2017) // C++ code generated with wxFormBuilder (version Aug 4 2017)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_ENV_VAR_CONFIG_BASE_H__ #ifndef __DIALOG_ENV_VAR_CONFIG_BASE_H__
@ -11,6 +11,8 @@
#include <wx/artprov.h> #include <wx/artprov.h>
#include <wx/xrc/xmlres.h> #include <wx/xrc/xmlres.h>
#include <wx/intl.h> #include <wx/intl.h>
class DIALOG_SHIM;
#include "dialog_shim.h" #include "dialog_shim.h"
#include <wx/listctrl.h> #include <wx/listctrl.h>
#include <wx/gdicmn.h> #include <wx/gdicmn.h>
@ -85,6 +87,7 @@ class DIALOG_ENV_VAR_SINGLE_BASE : public DIALOG_SHIM
wxButton* m_sdbSizer2Cancel; wxButton* m_sdbSizer2Cancel;
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void onVarNameChange( wxCommandEvent& event ) { event.Skip(); }
virtual void onHelpClick( wxCommandEvent& event ) { event.Skip(); } virtual void onHelpClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnSelectPath( wxCommandEvent& event ) { event.Skip(); } virtual void OnSelectPath( wxCommandEvent& event ) { event.Skip(); }

View File

@ -80,6 +80,6 @@ FILE_NAME_WITH_PATH_CHAR_VALIDATOR::FILE_NAME_WITH_PATH_CHAR_VALIDATOR( wxString
ENVIRONMENT_VARIABLE_CHAR_VALIDATOR::ENVIRONMENT_VARIABLE_CHAR_VALIDATOR( wxString* aValue ) : ENVIRONMENT_VARIABLE_CHAR_VALIDATOR::ENVIRONMENT_VARIABLE_CHAR_VALIDATOR( wxString* aValue ) :
wxTextValidator( wxFILTER_INCLUDE_CHAR_LIST | wxFILTER_EMPTY, aValue ) wxTextValidator( wxFILTER_INCLUDE_CHAR_LIST | wxFILTER_EMPTY, aValue )
{ {
wxString includeChars( wxT( "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_" ) ); wxString includeChars( wxT( "abcdefghijklmnopqrstuvwxyABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_" ) );
SetCharIncludes( includeChars ); SetCharIncludes( includeChars );
} }