Cocoa: DateTimePicker: mouse click is supported to select the date in the date selection view on MacOS, which is consistent with Windows

This commit is contained in:
rich2014 2023-06-28 20:25:11 +08:00
parent bf0878f8f9
commit b873d91b70
2 changed files with 6 additions and 1 deletions

View File

@ -16,6 +16,7 @@ type
TCocoaDatePicker = objcclass(NSDatePicker)
public
callback: ICommonCallback;
dateClicked: boolean;
autoResize: boolean;
retainAspectRatio: boolean;
@ -57,7 +58,8 @@ begin
// After mouse event, has our date changed
newDate:= NSDateToDateTime(Self.dateValue);
if (oldDate <> newDate) and Assigned(callback) then
dateClicked:= (oldDate <> newDate);
if dateClicked and Assigned(callback) then
callback.SendOnChange;
// This also calls OnClick....

View File

@ -111,6 +111,9 @@ end;
class function TCocoaWSCustomCalendar.HitTest(const ACalendar: TCustomCalendar; const APoint: TPoint): TCalendarPart;
begin
if TCocoaDatePicker(ACalendar.Handle).dateClicked then
exit(cpDate);
// need to validate this decision...
//Debugln('TCocoaWSCustomCalendar.HitTest Mouse Y : ' + IntToStr(APoint.y));
if APoint.y >= 40 then