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 previous message
fudadmin is currently offline  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

 
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: Sat Apr 20 07:36:48 CEST 2024

Total time taken to generate the page: 0.03914 seconds