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 » Limited EditString...- MaxChars [SOLVED AND FIXED...]
Limited EditString...- MaxChars [SOLVED AND FIXED...] [message #2183] Mon, 03 April 2006 16:11 Go to next message
fudadmin is currently offline  fudadmin
Messages: 1298
Registered: November 2005
Location: London, UK
Senior Contributor
Administrator
Quote:

1. I desire my user do not enter more than 25 character in the editName widget. It is not enough that a pink colour appear. I desire that the widget refuse to write any character further the 25th. Is there such limitation?


not very elegant solution but works:
class EditStringLim : public EditString {
	String str;
public:
typedef EditStringLim CLASSNAME;
void OnMax();
	EditStringLim();
	~EditStringLim() {;}
};

void EditStringLim::OnMax(){
	if (GetLength()>=maxlen){  //bad! but if you make only >maxlen the value becomes <error ...
		SetData(str);
		SetSelection(maxlen, maxlen); //to avoid "selected all"
	}
	else 
		str = GetData().ToString(); //.Left(maxlen);
}

EditStringLim::EditStringLim(){
	WhenAction=THISBACK(OnMax);
}

Any ideas how to make better?

Edit:
P.S. if you want to use your custom widgets with *.iml - paste or include them above
#define LAYOUTFILE "*.lay"

[Updated on: Sun, 09 April 2006 18:20]

Report message to a moderator

Re: Limited EditString... [message #2187 is a reply to message #2183] Mon, 03 April 2006 16:38 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11991
Registered: November 2005
Ultimate Member
fudadmin wrote on Mon, 03 April 2006 10:11

Quote:

1. I desire my user do not enter more than 25 character in the editName widget. It is not enough that a pink colour appear. I desire that the widget refuse to write any character further the 25th. Is there such limitation?


not very elegant solution but works:
class EditStringLim : public EditString {
	String str;
public:
typedef EditStringLim CLASSNAME;
void OnMax();
	EditStringLim();
	~EditStringLim() {;}
};

void EditStringLim::OnMax(){
	if (GetLength()>=maxlen){  //bad! but if you make only >maxlen the value becomes <error ...
		SetData(str);
		SetSelection(maxlen, maxlen); //to avoid "selected all"
	}
	else 
		str = GetData().ToString(); //.Left(maxlen);
}

EditStringLim::EditStringLim(){
	WhenAction=THISBACK(OnMax);
}

Any ideas how to make better?

Edit:
P.S. if you want to use your custom widgets with *.iml - paste or include them above
#define LAYOUTFILE "*.lay"


Well, I believe is that what forlano requests may not be desirable (at least, such limiting editing is very annoying in practice).

Mirek
Re: Limited EditString... [message #2189 is a reply to message #2187] Mon, 03 April 2006 16:53 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1298
Registered: November 2005
Location: London, UK
Senior Contributor
Administrator
Quote:

Well, I believe is that what forlano requests may not be desirable (at least, such limiting editing is very annoying in practice).


In my opinion, it is very annoying the authoritarian approach of U++ to user tastes, when some worldwide used features are exluded...
Re: Limited EditString... [message #2190 is a reply to message #2189] Mon, 03 April 2006 17:29 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11991
Registered: November 2005
Ultimate Member
fudadmin wrote on Mon, 03 April 2006 10:53

Quote:

Well, I believe is that what forlano requests may not be desirable (at least, such limiting editing is very annoying in practice).


In my opinion, it is very annoying the authoritarian approach of U++ to user tastes, when some worldwide used features are exluded...



Ok, ok... Puttin' to ToDo...

Mirek
Re: Limited EditString... [message #2191 is a reply to message #2190] Mon, 03 April 2006 17:49 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1298
Registered: November 2005
Location: London, UK
Senior Contributor
Administrator
luzr wrote on Mon, 03 April 2006 16:29

fudadmin wrote on Mon, 03 April 2006 10:53

Quote:

Well, I believe is that what forlano requests may not be desirable (at least, such limiting editing is very annoying in practice).


In my opinion, it is very annoying the authoritarian approach of U++ to user tastes, when some worldwide used features are exluded...



Ok, ok... Puttin' to ToDo...

Mirek


Sorry about that... Smile There's no rush. But I imagine how U++ users-programmers are frustrated when they waste time and they can't find what they had been used to...
Re: Limited EditString... [message #2193 is a reply to message #2191] Mon, 03 April 2006 21:02 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1062
Registered: March 2006
Location: Italy
Experienced Contributor
fudadmin wrote on Mon, 03 April 2006 17:49

luzr wrote on Mon, 03 April 2006 16:29

fudadmin wrote on Mon, 03 April 2006 10:53

Quote:

Well, I believe is that what forlano requests may not be desirable (at least, such limiting editing is very annoying in practice).


In my opinion, it is very annoying the authoritarian approach of U++ to user tastes, when some worldwide used features are exluded...



Ok, ok... Puttin' to ToDo...

Mirek


Sorry about that... Smile There's no rush. But I imagine how U++ users-programmers are frustrated when they waste time and they can't find what they had been used to...


To say the truth I found such option in many tools that are from far below U++ for power and widget richness. From other side the designer permits to limit the lenght of the string. I supposed that when this limit was reached no other imput was possibile... maybe some 'beep' is not bad to attract the attention of the user in this case. Instead now the user can continue to write and overcome the limit without problem. This is very annoying because when he realize the mistake he must delete the excedeed characters. To avoid the same experience he must keep his sight costantly on the screen to stop at the pink colour (... and delete one character). This way to proceed in my modest opinion is time consuming and not very friendly.
Thanks for the attention.
Luigi
Re: Limited EditString... [message #2195 is a reply to message #2193] Mon, 03 April 2006 21:31 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11991
Registered: November 2005
Ultimate Member
forlano wrote on Mon, 03 April 2006 15:02

fudadmin wrote on Mon, 03 April 2006 17:49

luzr wrote on Mon, 03 April 2006 16:29

fudadmin wrote on Mon, 03 April 2006 10:53

Quote:

Well, I believe is that what forlano requests may not be desirable (at least, such limiting editing is very annoying in practice).


In my opinion, it is very annoying the authoritarian approach of U++ to user tastes, when some worldwide used features are exluded...



Ok, ok... Puttin' to ToDo...

Mirek


Sorry about that... Smile There's no rush. But I imagine how U++ users-programmers are frustrated when they waste time and they can't find what they had been used to...


To say the truth I found such option in many tools that are from far below U++ for power and widget richness. From other side the designer permits to limit the lenght of the string. I supposed that when this limit was reached no other imput was possibile... maybe some 'beep' is not bad to attract the attention of the user in this case. Instead now the user can continue to write and overcome the limit without problem. This is very annoying because when he realize the mistake he must delete the excedeed characters. To avoid the same experience he must keep his sight costantly on the screen to stop at the pink colour (... and delete one character). This way to proceed in my modest opinion is time consuming and not very friendly.
Thanks for the attention.
Luigi


I think I owe you explanation - as it is designed now, it is not only about pink color (actually, that is recent month addition per users request). I agree that pink color is not enough.

However, there is usually a moment in GUI dialog lifetime when users acknowledges editations (usually by pressing OK butten). For that very moment there is an Accept method of TopWindow (it is automatically invoked if you bind OK button to your dialog using CtrlLayoutOKCancel). Accept method will, in case that there are any errors like this, stop the process and display error, setting focus to invalid widget.

Means while user is allowed to exceed EditString length for editational purposes, he is not allowed to accept invalid value (send to further processing).

Mirek
Re: Limited EditString... [message #2241 is a reply to message #2191] Wed, 05 April 2006 09:54 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11991
Registered: November 2005
Ultimate Member
fudadmin wrote on Mon, 03 April 2006 11:49

luzr wrote on Mon, 03 April 2006 16:29

fudadmin wrote on Mon, 03 April 2006 10:53

Quote:

Well, I believe is that what forlano requests may not be desirable (at least, such limiting editing is very annoying in practice).


In my opinion, it is very annoying the authoritarian approach of U++ to user tastes, when some worldwide used features are exluded...



Ok, ok... Puttin' to ToDo...

Mirek


Sorry about that... Smile There's no rush. But I imagine how U++ users-programmers are frustrated when they waste time and they can't find what they had been used to...


Added as "EditField::MaxChars".

(Available with next dev release... Wink

Mirek
Re: Limited EditString... [message #2270 is a reply to message #2241] Wed, 05 April 2006 15:10 Go to previous message
forlano is currently offline  forlano
Messages: 1062
Registered: March 2006
Location: Italy
Experienced Contributor
luzr wrote on Wed, 05 April 2006 09:54


Added as "EditField::MaxChars".

(Available with next dev release... Wink

Mirek


Thank you very much!
Luigi
Previous Topic: EditMinMax ctrl implementation
Next Topic: Why there is no WhenEnter for EditField?
Goto Forum:
  


Current Time: Thu Aug 22 18:51:25 CEST 2019

Total time taken to generate the page: 0.00933 seconds