Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » LineEdit, EditFields, DocEdit » filtering characters in the EditString [SOLVED...]
filtering characters in the EditString [SOLVED...] [message #2504] Sat, 15 April 2006 20:31 Go to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

I miss a feature that I believe it is very useful (maybe it is already present and I was unable to recognize it).

The EditString widget permit to enter a string but sometimes could be useful to prevent the user from entering useseless or dangerous characters. For example if I ask in input a name I would like to prevent the insertion of characters like: ',' '.' ':' ... '1' '2' etc ...
I think could be useful a new method like:

FilterEdit( ",.';" );

where the characters inside the string "..." are not permitted.

Maybe could be useful even some more method to restrict the string input. For example one that convert automatically the entered string in upper case (lower case). One that accept only alphanumeric avoiding all other characters: []()',. etc...

Thank you,
Luigi

[Updated on: Mon, 17 April 2006 05:09] by Moderator

Report message to a moderator

Re: filtering characters in the EditString [message #2509 is a reply to message #2504] Sun, 16 April 2006 04:01 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
First of all, the topic was in a wrong category -theIDE. This is a library question.
Second thing, I suggest you to learn Ctrl_Shift_F for "spying" packages for examples of usages.(candidate No1- ...ide Smile ) Double click on console result brings you to the appropriate file.
If you can't find anything usefull then ask if it exists (maybe under a different name).
If you find something similar try to check if this is just very easy to adapt to your case.

But when I did spying for you with "Filter", I've found that there is StrUtil.cpp with some similar functions.

e.g
D:\Devel_upp\uppsrc\ide\idewin.cpp(729):      ide.mainconfigparam = Filter(~arg[i] + 1, CommaSpace);

then jumping with "Go to derfinition" from CommaSpace,
ide brought me to idewin.cpp
int CommaSpace(int c)
{
	return c == ',' ? ' ' : c;
}


Maybe you can use them easily?
Edit: If not, show why not and apply on library wishlist... Smile

[Updated on: Sun, 16 April 2006 04:05]

Report message to a moderator

Re: filtering characters in the EditString [message #2510 is a reply to message #2509] Sun, 16 April 2006 04:20 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
Moreover, have you tried e.g

editName.SetFilter(...); ?
Re: filtering characters in the EditString [message #2511 is a reply to message #2510] Sun, 16 April 2006 04:36 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
below your let's say Avail3
#include "VegaMain.h"

void Avail3(One<Ctrl>& ctrl)
{
	//	ctrl.Create<Option>().ThreeState();
	ctrl.Create<OptionImage>().ThreeState().SetImage(imgYes(), imgNo(), imgMaybe());
	
}

int FilterCommaSpace(int c)
{
	if (c == ',' || c ==' ') return false; //add more unwanted chars here..
	else return c;
}

...
...
void VegaTab1::MaskDefaultValue() // body of the callback
{
	editName <<= Null;
	editName.SetFilter(FilterCommaSpace); //added filter
...


Edit: It looks like you even didn't spy EditString! ...

[Updated on: Sun, 16 April 2006 04:39]

Report message to a moderator

Re: filtering characters in the EditString [message #2513 is a reply to message #2511] Sun, 16 April 2006 08:39 Go to previous message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
fudadmin wrote on Sun, 16 April 2006 04:36

below your let's say Avail3
#include "VegaMain.h"

void Avail3(One<Ctrl>& ctrl)
{
	//	ctrl.Create<Option>().ThreeState();
	ctrl.Create<OptionImage>().ThreeState().SetImage(imgYes(), imgNo(), imgMaybe());
	
}

int FilterCommaSpace(int c)
{
	if (c == ',' || c ==' ') return false; //add more unwanted chars here..
	else return c;
}

...
...
void VegaTab1::MaskDefaultValue() // body of the callback
{
	editName <<= Null;
	editName.SetFilter(FilterCommaSpace); //added filter
...


Edit: It looks like you even didn't spy EditString! ...


Embarassed Crying or Very Sad Embarassed
Previous Topic: Shift-Backspace should also delete in TextCtrls [FIXED][ADDED]
Next Topic: Which widget can show text with fixed font?
Goto Forum:
  


Current Time: Thu Mar 28 19:27:53 CET 2024

Total time taken to generate the page: 0.01256 seconds