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 » EditTime - how to change format?- [SOLVED]-EditField & Convert
Re: EditTime - Is it possible to change displayed format? [message #36847 is a reply to message #570] Wed, 11 July 2012 18:57 Go to previous message
lectus is currently offline  lectus
Messages: 329
Registered: September 2006
Location: Brazil
Senior Member
Garry wrote on Mon, 09 January 2006 17:26


Anyway, here's my code now:


Thanks to your code I managed to understand how to do validation for my own code.
I wanted the user to be able to only input time in the format hh:mm.

Here's the solution:
1) I put one EditString called "e" and one Button called "b" in the layout.

2) Add this code:
// Custom character filter
class MyTimeConvert: public Convert {

	public:
	int Filter(int chr) const {
		if(IsDigit(chr) || chr == ':')                        //only accepts digits and ":"
			return chr;
		return 0;
	}
};

// Validation callback. Uses regular expressions:
void MainWin::ValidateTime()
{
	RegExp r0("\\d\\d:\\d\\d");
	if (!r0.Match(~e))
		Exclamation("Invalid time!");
}

e.MaxChars(5); // limit it to 5 chars
e.SetConvert(Single<MyTimeConvert>()); // sets custom filtering
b.WhenPush = THISBACK(ValidateTime); // when clicked check for format hh:mm.

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Trouble with EditTime
Next Topic: DocEdit code scrolling
Goto Forum:
  


Current Time: Sun Apr 28 07:21:10 CEST 2024

Total time taken to generate the page: 0.06648 seconds