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 |
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.
|
|
|
Goto Forum:
Current Time: Sat May 11 17:31:55 CEST 2024
Total time taken to generate the page: 0.02693 seconds
|