TwwCalendarEdit changing value when user doesn't & failing to notify binding
Given an empty wwCalendarEdit, i.e. blank text value, the behavior of the calendar is to set the date when dropping down the selector, before a date is selected by the user. The calendar continues to change the date as the user navigates the selector. The preferred behavior is the edit remain blank until the user explicitly selects a date on the calendar.
That is a behavior preference. The problem I'm seeing is the default date assigned when dropping down the calendar on an empty edit does not notify the bound TField the value changed, which would result in the dataset going to edit. This gives the user the appearance a date, usually today for blank edits, has been assigned when it hasn't because the bound TField has not taken the value.
This sample project explains & illustrates the problem.
https://www.dropbox.com/s/mza8z3swxfi262d/wwCalendar.zip?dl=0
-
I found a workaround to default to today's date when Text = '' and dataset not put into edit problem.
In TwwCalendarEdit.DropDown, comment out the following lines (3606 - 3610):
// if DateTime = 0.0 then
// begin
// if not IsTimeOnlyField then
// DateTime := System.SysUtils.Date;
// end;Add the following code just before FListPicker.Show:
if DateTime = 0.0 then
begin
if not IsTimeOnlyField then
FListPicker.Date := System.SysUtils.Date;
end;
FListPicker.Show;This will force the user to select a date & cause the dataset to go into edit.
Now, how to stop navigating the calendar changing the edit value & reserve such an event for when the user selects a value. Hmm... a little tougher since it's contra-Delphi's default behavior for this control.
Please sign in to leave a comment.
Comments
1 comment