|
|
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 |
|
fudadmin
Messages: 1321 Registered: November 2005 Location: Kaunas, Lithuania
|
Ultimate 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 #2195 is a reply to message #2193] |
Mon, 03 April 2006 21:31 |
|
mirek
Messages: 14105 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... 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
|
|
|
|
|
Goto Forum:
Current Time: Fri Nov 01 00:08:28 CET 2024
Total time taken to generate the page: 0.03611 seconds
|
|
|