Discussions related to Visual Prolog
B.Hooijenga
VIP Member
Posts: 57
Joined: 11 Jul 2002 23:01

DateControl: two events instead of one

Unread post by B.Hooijenga »

Hello,

I use the DateTimeChangedListener in DateControl.
When I use the mouse in the calendar I always get two events instead of one.
Using the keyboard gives no problem.

Is this normal?

I made a workaround which seems ok, but I am not sure about it.

Code: Select all

predicates     onDateControlDateTimeChanged : dateControl::dateTimeChangedListener. clauses     onDateControlDateTimeChanged(_Source) :-         T =dateControl_ctl:gmtTimeValue,         stdio::write(T,"\n"). % Do something here   %workaround %facts %    datetime : gmtTimeValue := erroneous. %predicates %    onDateControlDateTimeChanged : dateControl::dateTimeChangedListener. %clauses %    onDateControlDateTimeChanged(_Source) :- %        T =dateControl_ctl:gmtTimeValue, %        if isErroneous(datetime) %            then %                stdio::write(T,"\n"), % Do something here %                datetime := T %            else %                datetime:=erroneous %        end if.
Kind regards,

Ben
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

The dateControl is the Date and Time Picker.

Our own programs uses another (home made) date control, so we don't really have large experience with the standard .

However searching the Internet seems to show that you are not the only one with such problems (and I can also reproduce it).

Regarding your work-around, why not just do something when the time is different from the previous one (i.e. rather than toggling between erroneous and valid):

Code: Select all

facts     previousGmtTimeValue : gmtTimeValue := 0.  % zero will serve well as an initial value   predicates     onDateControlDateTimeChanged : dateControl::dateTimeChangedListener. clauses     onDateControlDateTimeChanged(_Source) :-         T = dateControl_ctl:gmtTimeValue,         if previousGmtTimeValue <> T then             stdio::write(T, "\n")         end if,         previousGmtTimeValue := T.
Regards Thomas Linder Puls
PDC
B.Hooijenga
VIP Member
Posts: 57
Joined: 11 Jul 2002 23:01

Unread post by B.Hooijenga »

Thanks Thomas,

I used my solution because I am not absolutely sure that two timevalues for one event are ALWAYS equal.
Because - according to the helpfile - GMT-based date/time information is stored in gmtTime type objects with 100-nanosecond precision.
Is there one object used twice? Or two objects and could they have different values?

Perhaps I am seeing a ghost, but if it happens that they are unequal then your code-suggestion could give problems.
Because the two work-arounds have a different meaning:
Your solution says: act if there is a time-difference.
My solution says: act if we are here for the first time in this event.

Kind regards,

Ben.
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

I believe you skip every second event, but as you said there is only one event when using the keyboard.

On the other hand, I think it is correct to say that the control have changed if the time it represents have changed.
Regards Thomas Linder Puls
PDC
Post Reply