U++ framework
Do not panic. Ask here before giving up.

Home » U++ Library support » LineEdit, EditFields, DocEdit » Limited EditString...- MaxChars [SOLVED AND FIXED...]
Re: Limited EditString... [message #2187 is a reply to message #2183] Mon, 03 April 2006 16:38 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14291
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
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: EditMinMax ctrl implementation
Next Topic: Why there is no WhenEnter for EditField?
Goto Forum:
  


Current Time: Fri May 15 07:30:23 GMT+2 2026

Total time taken to generate the page: 0.01318 seconds