有没有办法用FireMonkey添加提示或工具提示? [英] Is there any way to add a hint or tooltip with FireMonkey?
问题描述
理想情况下,我正在寻找类似这样的东西(标注类型的工具提示):
已经将这个问题搁置的主持人:我正在寻找如何实现这一点的源代码,而不是购买/使用的软件。目前(AFAIK)没有源代码组件可以做到这一点,所以没有意见不端或垃圾邮件的风险。
这是我最终做到的:为Button创建一个提示,如下所示:
向表单添加按钮。然后添加一个TPopup。在其中放置一个CalloutPanel,并可选择将对齐方式设置为AlClient。在该CalloutPanel上放置一个TLabel,并写下您的提示文字。
您的结构应如下所示:
然后转到TPopup并将PlacementTarget设置为Button1(您的按钮)。接下来,转到Placement并选择BottomCenter:
接下来在按钮上添加一个MouseEnter和MouseLeave事件的处理程序:
procedure TForm1.Button1MouseEnter(Sender:TObject);
begin
Popup1.IsOpen:= True;
结束
程序TForm1.Button1MouseLeave(Sender:TObject);
begin
Popup1.IsOpen:= False;
结束
应该这样做。
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):
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".
This is how I finally did it: to create a hint for a Button that looks like this:
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:
Then go to the TPopup and set PlacementTarget to Button1 (your button). Next, go to Placement and select BottomCenter:
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.
这篇关于有没有办法用FireMonkey添加提示或工具提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!