wxFILTER_EXCLUDE_LIST

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
MuhammadSohail
Experienced Solver
Experienced Solver
Posts: 96
Joined: Fri Jun 17, 2005 1:53 pm
Location: Germany

wxFILTER_EXCLUDE_LIST

Post by MuhammadSohail »

i am using WXv2.5.4. and using validator wxFILTER_EXCLUDE_LIST ,wxFILTER_INCLUDE_LIST in the wxTextControl but it is not working properly. is it a wxWidgtes Bug or should i do something else????

thanks[/u]
upCASE
Moderator
Moderator
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Re: [b]wxFILTER_EXCLUDE_LIST[/b]

Post by upCASE »

Muhammad Sohail wrote:i am using WXv2.5.4. and using validator wxFILTER_EXCLUDE_LIST ,wxFILTER_INCLUDE_LIST in the wxTextControl but it is not working properly.
Could you post some code?
And what does "not working properly" mean?
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
MuhammadSohail
Experienced Solver
Experienced Solver
Posts: 96
Joined: Fri Jun 17, 2005 1:53 pm
Location: Germany

Post by MuhammadSohail »

wxTextCtrl(this, -1, wxString(""), wxPoint(-1, -1), wxSize(-1, -1), 0, wxTextValidator(wxFILTER_EXCLUDE_LIST , &wxString("*:")));

i dont want to write * and : in the text control . but its not functioning .
any solution???

thanks
priyank_bolia
wxWorld Domination!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA

Post by priyank_bolia »

Well I Uses this:

Code: Select all

	wxArrayString numberArray;
	numberArray.Add(wxT("0"));
	numberArray.Add(wxT("1"));
	numberArray.Add(wxT("2"));
	numberArray.Add(wxT("3"));
	numberArray.Add(wxT("4"));
	numberArray.Add(wxT("5"));
	numberArray.Add(wxT("6"));
	numberArray.Add(wxT("7"));
	numberArray.Add(wxT("8"));
	numberArray.Add(wxT("9"));
	wxTextValidator textValidatorRelax(wxFILTER_INCLUDE_CHAR_LIST, &m_strRelax);
	textValidatorRelax.SetIncludes(numberArray);
	m_pRelaxEdit = new wxTextCtrl(this, ID_WXEDIT_RELAX, wxT(""), wxPoint(155,23), wxSize(45,20), wxTE_LEFT, textValidatorRelax, wxT("WxEditRelax"));
priyank_bolia
wxWorld Domination!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA

Post by priyank_bolia »

wxTextValidator does not take exclude/include list in the constructor, but the string on which to check, the string contains the value of the textctrl.
upCASE
Moderator
Moderator
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE »

Muhammad Sohail wrote:wxTextCtrl(this, -1, wxString(""), wxPoint(-1, -1), wxSize(-1, -1), 0, wxTextValidator(wxFILTER_EXCLUDE_LIST , &wxString("*:")));

i dont want to write * and : in the text control . but its not functioning .
any solution???
The last parameter doesn't contain the exclude list, but will store the value once it's validated.

Use priyank_bolia code, but set an exclude list.
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
MuhammadSohail
Experienced Solver
Experienced Solver
Posts: 96
Joined: Fri Jun 17, 2005 1:53 pm
Location: Germany

Post by MuhammadSohail »

thanks , its working now

wxArrayString excludeList;
excludeList.Add(wxT("*"));
excludeList.Add(wxT(":"));
excludeList.Add(wxT("\\"));
excludeList.Add(wxT("/"));
excludeList.Add(wxT("?"));
excludeList.Add(wxT("\""));
excludeList.Add(wxT("<"));
excludeList.Add(wxT(">"));
excludeList.Add(wxT("|"));
excludeList.Add(wxT(" "));
wxTextValidator textValidator(wxFILTER_EXCLUDE_CHAR_LIST);
textValidator.SetExcludes(excludeList);

textCtrl = new wxTextCtrl(this, -1, wxString(""), wxPoint(-1, -1), wxSize(-1, -1), 0, textValidator);

this code doesnot permit the user to write the excludeList Characters.

thnaks again
vasek
Experienced Solver
Experienced Solver
Posts: 77
Joined: Wed Jul 27, 2005 2:52 pm
Location: Ostrava, Czech Republic

Post by vasek »

maybe regular expression validator could help -- i've posted one in code dump :)