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
|
|
|
Goto Forum:
Current Time: Thu May 02 22:58:06 CEST 2024
Total time taken to generate the page: 0.03550 seconds
|