Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to add a hint or tooltip with FireMonkey?

I've earched for it but couldn't find anything. Is there any way to add a hint or tooltip with FireMonkey? Are there any components available that enable this?

Ideally I am looking for something like this (a callout type tooltip):

a callout type tooltip

To the moderators who have placed this question on hold: I am looking for lines of source code on how to achieve this, not a software to buy/use. There are currently (AFAIK) no source code components that enable doing this, so there is no risk of "opinionated anwers or spam".

like image 445
Jamie Avatar asked Mar 14 '14 23:03

Jamie


1 Answers

This is how I finally did it: to create a hint for a Button that looks like this:

enter image description here

Add a button to a form. Then add a TPopup. Drop a CalloutPanel inside it and optionally set the align to AlClient. The drop a TLabel on that CalloutPanel and write your hint text.

Your structure should look like this:

enter image description here

Then go to the TPopup and set PlacementTarget to Button1 (your button). Next, go to Placement and select BottomCenter:

enter image description here

Next add a handler for the MouseEnter and MouseLeave events on the button:

procedure TForm1.Button1MouseEnter(Sender: TObject);
begin
Popup1.IsOpen := True;
end;

procedure TForm1.Button1MouseLeave(Sender: TObject);
begin
Popup1.IsOpen := False;
end;

That should do it.

like image 56
Jamie Avatar answered Oct 01 '22 19:10

Jamie