Delphi 10.1 Firemonkey - detection of a mouse click outside a component

How to detect a mouse click outside a component? I set up a calendar and when I click on TLabel with the date presented, TCalendar appears. It works. But I want to disappear TCalendar when the mouse is outside the component and the button is pressed? In VCL, I can use WindowsMessages, but there is Firemonkey, and I also want to use it in iOS.

BR

+4
source share
1 answer

Try it. He moves the mouse to the screen (Win, iOs, Android). So you can use this to find when the cursor is out of your control. And for MouseDown, try using MouseDown on the form.

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

Source: https://habr.com/ru/post/1662029/


All Articles