Home » U++ Library support » CalendarCtrl » DropTime problem
DropTime problem [message #19556] |
Mon, 15 December 2008 15:27 |
Tom1
Messages: 1212 Registered: March 2007
|
Senior Contributor |
|
|
Hi,
I'm using the DropTime control for entering time/date. I have set up the environment as follows.
SetDateScan("ymd");
SetDateFormat("%1:04d-%2:02d-%3:02d");
SetDateFilter("\a -.,/");
The date set in code or if selected from the calendar is correctly visualized e.g. for the current time as: "2008-12-15 16:20:55".
Now I'm trying to type in the desired date into the DropTime control, but it is impossible to feed the '-' character (hyphen/dash/minus/whatever) into the control. It seems, only . : and space work correctly as delimiters. I can't seem to find where the characters get filtered out. Help, anybody?
// Tom
|
|
|
Re: DropTime problem [message #19560 is a reply to message #19556] |
Mon, 15 December 2008 18:22 |
Sender Ghost
Messages: 301 Registered: November 2008
|
Senior Member |
|
|
Tom1 wrote on Mon, 15 December 2008 19:27 | Hi,
I'm using the DropTime control for entering time/date. I have set up the environment as follows.
SetDateScan("ymd");
SetDateFormat("%1:04d-%2:02d-%3:02d");
SetDateFilter("\a -.,/");
The date set in code or if selected from the calendar is correctly visualized e.g. for the current time as: "2008-12-15 16:20:55".
Now I'm trying to type in the desired date into the DropTime control, but it is impossible to feed the '-' character (hyphen/dash/minus/whatever) into the control. It seems, only . : and space work correctly as delimiters. I can't seem to find where the characters get filtered out. Help, anybody?
// Tom
|
Hello, Tom.
You can see ConvertTime in the "Core/Convert.cpp":
int ConvertTime::Filter(int chr) const
{
if(IsDigit(chr) || chr == ' ' || chr == '.' || chr == ':')
return chr;
if(chr == ',')
return '.';
return 0;
}
DropTime using it in the EditTime:
typedef EditMinMax<Time, ConvertTime> EditTime;
DropTime::DropTime() : DateTimeCtrl<EditTime>(CalendarClock::MODE_TIME) {}
[Updated on: Mon, 15 December 2008 18:58] Report message to a moderator
|
|
|
Re: DropTime problem [message #19564 is a reply to message #19560] |
Tue, 16 December 2008 13:00 |
Tom1
Messages: 1212 Registered: March 2007
|
Senior Contributor |
|
|
Hi,
Thanks! Now here's a suggestion: Change code in Core/Convert.cpp as follows:
int ConvertTime::Filter(int chr) const
{
if(IsDigit(chr) || chr == ' ' || chr == '.' || chr == ':')
return chr;
if(chr == ',')
return '.';
return CharFilterDate(chr);
}
Time is not only hh:mm:ss, but also contains date in some format. I assume the filter should therefore accept the current date filter characters too.
// Tom
|
|
|
Re: DropTime problem [message #19566 is a reply to message #19564] |
Tue, 16 December 2008 16:02 |
Sender Ghost
Messages: 301 Registered: November 2008
|
Senior Member |
|
|
Tom1 wrote on Tue, 16 December 2008 17:00 | Hi,
Thanks! Now here's a suggestion: Change code in Core/Convert.cpp as follows:
int ConvertTime::Filter(int chr) const
{
if(IsDigit(chr) || chr == ' ' || chr == '.' || chr == ':')
return chr;
if(chr == ',')
return '.';
return CharFilterDate(chr);
}
Time is not only hh:mm:ss, but also contains date in some format. I assume the filter should therefore accept the current date filter characters too.
// Tom
|
Why not use your implementation of DropTime widget ctrl? For example:
class MyConvertTime : public ConvertTime {
public:
virtual int Filter(int chr) const
{
int c = CharFilterDate(chr);
if (c != 0) return c;
else return ConvertTime::Filter(chr);
}
};
typedef EditMinMax<Time, MyConvertTime> MyEditTime;
class MyDropTime : public DateTimeCtrl<MyEditTime> {
public:
MyDropTime();
MyDropTime& SetTime(int y, int m, int d, int h, int n, int s);
MyDropTime& Seconds(bool b = true) { DateTimeCtrl<MyEditTime>::Seconds(b); MyEditTime::Seconds(b); return *this; }
MyDropTime& NoSeconds() { return Seconds(false); }
};
MyDropTime::MyDropTime() : DateTimeCtrl<MyEditTime>(CalendarClock::MODE_TIME)
{}
MyDropTime& MyDropTime::SetTime(int y, int m, int d, int h, int n, int s)
{
MyEditTime::SetData(Time(y, m, d, h, n, s));
return *this;
}
[Updated on: Tue, 16 December 2008 17:46] Report message to a moderator
|
|
|
Re: DropTime problem [message #19567 is a reply to message #19566] |
Tue, 16 December 2008 16:38 |
Tom1
Messages: 1212 Registered: March 2007
|
Senior Contributor |
|
|
Although your workaround seems smart indeed, I prefer simply having it fixed in the Core, since then everybody using the control can have a working solution by default.
But thanks anyway!
// Tom
|
|
|
Re: DropTime problem [message #19568 is a reply to message #19567] |
Tue, 16 December 2008 17:14 |
Sender Ghost
Messages: 301 Registered: November 2008
|
Senior Member |
|
|
Tom1 wrote on Tue, 16 December 2008 20:38 | Although your workaround seems smart indeed, I prefer simply having it fixed in the Core, since then everybody using the control can have a working solution by default.
But thanks anyway!
// Tom
|
I can suggest another more simple solution:
class ConvertDateTime : public ConvertTime
{
public:
virtual int Filter(int chr) const
{
int c = CharFilterDate(chr);
if (c != 0) return c;
else return ConvertTime::Filter(chr);
}
};
Then use ConvertDateTime with DropTime (e.g. dropTime) as follows:
dropTime.SetConvert(Single<ConvertDateTime>());
Also you can see SetFilter function of DropTime.
[Updated on: Tue, 16 December 2008 18:25] Report message to a moderator
|
|
|
|
Re: DropTime problem [message #19579 is a reply to message #19574] |
Thu, 18 December 2008 11:29 |
Tom1
Messages: 1212 Registered: March 2007
|
Senior Contributor |
|
|
Hi Mirek,
I used this solution and it worked for me, but I assume it's the correct fix more generally as well. I could not spot it on SVN yet, but I suppose you will commit it shortly.
Thanks and regards,
Tom
|
|
|
|
Goto Forum:
Current Time: Thu Apr 25 01:57:14 CEST 2024
Total time taken to generate the page: 0.04569 seconds
|