Question

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".

Was it helpful?

Solution

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.

OTHER TIPS

You can use FloatAnimation and Opacity property to make a hint.

Add a button to a form. Then add CalloutPanel (or any shape) inside. Next drop a TLabel on the CalloutPanel to write your hint text. I set CalloutPanel.Visible property to False at the Form Creating moment. Then attach a TFloatAnimation to a CalloutPanel.Opacity property.

Next set some TFloatAnimation properties:

Because of Duration Hint appears smoothly.

Then create Button events OnMouseEnter and OnMouseLeave .

procedure TForm1.Button1MouseEnter(Sender: TObject);
begin
   CalloutPanel1.Visible := true;
end;

procedure TForm1.Button1MouseLeave(Sender: TObject);
begin
   CalloutPanel1.Visible := false;
end;

That's it

I am new to Delphi and FireMonkey. And I also wanted tool tips. And here is what I figured out: FireMonkey has no provision for tool tips, and this is deliberate and for good reason.

I think the big idea with FireMonkey is that you develop one and only one program. Then, without changing even one line of code, you compile a version to run on Windows, another version to run on Android, another version to run on Mac OS, etc. So without changing even one line of code, you have a version for Desktop and a version for Smartphones that work exactly the same way with the same user interface.

Therefore, FireMonkey is only going to support features that are common to both smartphones and desktops. On smartphones, there is no such thing as hovering a mouse, a finger, or anything else. Therefore, Firemonkey does not support hovering on desktops. Because there is no hovering, there can be no tooltips ('hints' in Delphi nomenclature).

So you have to decide: Do you want an app that works exactly the same in Windows and on smartphones, without changing the code and without having separate code? Or do you want all the desktop features? If you want all the desktop features, including tooltips (hints) and all the rest, then you should be using Embarcadero's VCL (Visual Component Library). Using VCL will allow you to get tooltips (hints) by just setting the 'hint' property of text boxes, buttons, and all the other controls--and without writing code.

But if you want an app that works on smartphones, you will have to use FireMonkey. VCL won't work for that.

As I mentioned, I'm still new to Delphi. So, of course, I appreciate corrections from experienced Delphi developers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top