有没有事件可以确定鼠标是否悬停在编辑框上?基本上,我想为用户显示提示/帮助,但我想显示一张图片和简单的说明。最好的方法是什么?
感谢任何帮助。
有没有事件可以确定鼠标是否悬停在编辑框上?基本上,我想为用户显示提示/帮助,但我想显示一张图片和简单的说明。最好的方法是什么?
感谢任何帮助。
OnMouseEnter
和OnMouseLeave
事件。在事件处理程序中,您可以设置带有提示文本的Label
或类似控件的可见性。在此示例中,我使用了一个空的VCL表单,并插入了一个TEdit
和一个TLabel
。我实现了OnMouseMEnter
和OnMouseLeave
事件: TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
procedure Edit1MouseEnter(Sender: TObject);
procedure Edit1MouseLeave(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Edit1MouseEnter(Sender: TObject);
begin
Label1.Visible:=True;
end;
procedure TForm1.Edit1MouseLeave(Sender: TObject);
begin
Label1.Visible:=False;
end;
OnMouseEnter
和 OnMouseLeave
事件。这是在Embarcadero上找到的示例:
type
TForm1 = class(TForm)
Button1: TButton;
StatusBar1: TStatusBar;
Edit1: TEdit;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
procedure DisplayHint(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ Here is the implementation of the OnHint event handler }
{ It displays the application’s current hint in the status bar }
procedure TForm1.DisplayHint(Sender: TObject);
begin
StatusBar1.SimpleText := GetLongHint(Application.Hint);
end;
{ Here is the form’s OnCreate event handler. }
{ It assign’s the application’s OnHint event handler at runtime }
{ because the Application is not available in the Object Inspector }
{ at design time }
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnHint := DisplayHint;
end;
TLabel
的 HINT 属性上使用特殊标记,然后根据需要管理输出。TApplicationEvents
而不是直接分配给TApplication.OnHint
。 - David Heffernan
TApplication.OnHint
- TLama