How to get the control under the mouse in the onMouseDown event?

I have a TGridLayout filled with some images in a Firemonkey HD application . In the gridLayout onMouseDown event, I want to get the image object that the user clicked on, but I only have the mouse coordinates.

The implementation of the onMouseDown event for each image is not an option, because if the image is removed from the gridlayout, there is empty space. In this case, I also want to find out if the user clicked in this empty area.

Is there any analogue of "getChildAtPos" or "FindVCLWindow" in Firemonkey ?

Thanks!

+4
source share
2 answers

TForm.ObjectAtPoint should do the trick.

+5
source

FindVCLWindow does what you need. You need to specify the point at which the control is located, in your case this is the position of the mouse.

0
source

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


All Articles