Forum > LCL
Problem with Hints
simsee:
I try to simplify a simple problem that arises in a more complex context, about hints.
Suppose we have two controls visible on the screen. The rectangular perimeter around the larger one contains the smaller one. Let's also assume that the larger one is placed in the foreground (with BringToFront method), while the smaller one is placed in the background (with SendToBack method).
If the shape of the larger control is not rectangular, the other control is still visible. My problem is that in this case, when the mouse cursor goes over the smaller control, is displayed the hint of the larger one, not the hint of the smaller one, above which the cursor visually appears.
Is it possible to solve this problem?
Attached I show an example made with Shapes and two screenshots that show the problem.
Thanks.
Alexandr R:
Hint срабатывает на прямоугольнную область в которой расположена фигура. Если прямоугольные области TShare не перекрываются всё работает отлично. Наверное Вам надо сначала определить, что указатель мыши находится внутри или на границе замкнутой фигуры (звезды или квадрата в Вашем примере) и только потом отобразить Hint (например используя THintWindiw).
Hint is triggered by the rectangular area in which the figure is located. If the rectangular areas of TShare do not overlap, everything works fine. Probably you need to first determine that the mouse pointer is inside or on the border of a closed figure (a star or a square in your example) and only then display the Hint (for example, using THintWindiw).
Handoko:
--- Quote from: simsee on December 03, 2024, 12:21:44 pm ---Is it possible to solve this problem?
--- End quote ---
Sorry if it is off topic and maybe not what you want.
It seems you're developing some sort of graphics engine, if yes you really should study Mr.Madguy's sprite picking example code:
https://forum.lazarus.freepascal.org/index.php/topic,36871.msg246309.html#msg246309
That is about object detection for 2D graphics. If all the items have basic geometry shapes, rectangle for example you just need to loop the z-order and compare your mouse position with the shape's left-top most and right-bottom most coordinates. But if they have varies or irregular shapes, you need to use a different method. Mr.Madguy provided a fully working code for irregular shape sprite picking technique, it's maybe too advanced for beginners to understand, but with some patient studying to code, it's really worth your time.
After you understand how it works, you can easily write your own hint that works on any shapes.
lainz:
In bgracontrols we use alpha channel to detect transparent areas.
Check bcimagebutton control.
simsee:
Thanks for the replies.
I'm able to determine if the mouse is actually over a shape or not, with more or less complex mathematical formulas depending on the type of shape.
My problem is: once I have ascertained that the mouse is over a shape, how do I trigger the visualization of the hint? As far as I know the hint is always or never displayed in a control depending on the true or false value of its ShowHint property.
Navigation
[0] Message Index
[#] Next page