Page 1 of 1

wxTextValidator and Filter range

Posted: Wed Jul 22, 2009 8:44 am
by MuhammadSohail
Hallo all,
Is there any possibility to define a filter with specific range?

e.g.
I only want to filter following chracters for my password in the wxTextCtrl

A - Z
a - z
0 - 9

Posted: Thu Jul 30, 2009 10:41 am
by MuhammadSohail

Code: Select all

wxArrayString includeList;
	for (size_t i = 65; i <= 90 ; i++)
	{
		std::stringstream alpha;
		alpha << (char) i;
		includeList.Add( wxT(alpha.str()) );
	}
	for (size_t i = 97; i <= 122 ; i++)
	{
		std::stringstream alpha;
		alpha << (char) i;
		includeList.Add( wxT( alpha.str()) );
	}
	includeList.Add(wxT("0"));
	includeList.Add(wxT("1"));
	includeList.Add(wxT("2"));
	includeList.Add(wxT("3"));
	includeList.Add(wxT("4"));
	includeList.Add(wxT("5"));
	includeList.Add(wxT("6"));
	includeList.Add(wxT("7"));
	includeList.Add(wxT("8"));
	includeList.Add(wxT("9"));

wxTextValidator  validator(wxFILTER_INCLUDE_CHAR_LIST);
validator.SetIncludes(includeList);

Posted: Wed Oct 14, 2009 8:58 am
by ngpaton
Hi,

Can't you just use:

Code: Select all

wxTextValidator  validator(wxFILTER_ALPHANUMERIC);
Otherwise the validator will have to search through the list of includes for every character entry. I assume the above uses the isalnum() macro instead which will be much more efficient.

Cheers

Nigel