Delphi 10.1 Firemonkey - 检测组件外的鼠标点击

Delphi 10.1 Firemonkey - Detecting the mouse click outside the component

如何检测组件外的鼠标点击? 我正在制作自定义日历,当单击带有显示日期的 TLabel 时 - TCalendar 出现了。它的工作。但是当鼠标在组件外并按下按钮时,我想使 TCalendar 消失吗?在 VCL 中,我可能会使用 WindowsMessages,但是有一个 Firemonkey,我也想在 iOS 上使用它。

BR

试试这个。它在屏幕上获取鼠标位置(Win,iOs,Android)。因此,您可以使用它来查找光标何时超出您的控制范围。对于 MouseDown,请尝试在 Form 上使用 MouseDown。

function MousePos: TPointF;
var
  MouseService: IFMXMouseService;
begin
  if TPlatformServices.Current.SupportsPlatformService(IFMXMouseService, IInterface(MouseService)) then
    Exit(MouseService.GetMousePos);
  Result := PointF(0, 0);
end;