【问题标题】:Mouseover Image On Buttons In FMX XE2FMX XE2中按钮上的鼠标悬停图像
【发布时间】:2014-02-15 23:15:10
【问题描述】:

如何为按钮制作鼠标悬停图像? 我曾经制作 FMX 2 按钮,并用位图填充它。但它很糟糕。 我找到了属性IsMouseOver

procedure TForm1.Button1Paint(Sender: TObject; Canvas: TCanvas;
  const ARect: TRectF);
begin
if Button1.IsMouseOver  then
begin
  Button1.Text:='yes';
end
else
begin
  Button1.Text:='nono';
end;
end;

但是,我真的不明白如何使用容器,我只想通过之前写的方法更改填充(我的位图)。谁能给个简单的代码?

或者也许它更容易在 VCL 中制作?

【问题讨论】:

    标签: delphi firemonkey firemonkey-fm2


    【解决方案1】:

    在按钮上放置两个单独的TImage 控件(将它们拖到结构视图中的按钮上):

    调整它们的大小以适合按钮,并使用 MultiResBitmap 属性编辑器为每个单独的图像分配一个图像。

    OnMouseEnterOnMouseLeave 事件的TImage 组件之一创建事件处理程序,然后将这些处理程序分配给TImage 两个组件:

    procedure TForm1.Image1MouseEnter(Sender: TObject);
    begin
      Image1.Visible := False;
      Image2.Visible := True;
    end;
    
    procedure TForm1.Image1MouseLeave(Sender: TObject);
    begin
      Image1.Visible := True;
      Image2.Visible := False;
    end;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多