Delphi Firemonkey中的鼠标事件动画

发布于 2024-12-10 19:13:53 字数 773 浏览 0 评论 0原文

我添加了一个按钮并向其添加了一个 BoxBlurEffect,并将以下属性设置为 BoxBlurEffect1

//extracted form fmx file 

object BoxBlurEffect1: TBoxBlurEffect
  Trigger = 'IsMouseOver=true'
  Enabled = False
  BlurAmount = 0.009999999776482582
  object FloatAnimation1: TFloatAnimation
    AnimationType = atInOut
    Enabled = True
    Duration = 1.000000000000000000
    Loop = True
    Trigger = 'IsMouseOver=true'
    TriggerInverse = 'IsMouseOver=false'
    StartValue = 0.009999999776482582
    StopValue = 10.000000000000000000
    PropertyName = 'BlurAmount'
  end
end

我设置了loop = true,因为如果它是false,它就不会动画,它只是突然达到最终值。

所以我把它设置为true。但现在它是循环的(正如名称所描述的),而不仅仅是动画一次然后停止。

而且我还希望当我离开鼠标时它从停止值动画到开始值(仅一次)。当我的鼠标离开或进入时,新动画必须从当前值开始,而不是从最大值或最小值开始。

I have added a button and added a BoxBlurEffect to it and set following attributes to the BoxBlurEffect1.

//extracted form fmx file 

object BoxBlurEffect1: TBoxBlurEffect
  Trigger = 'IsMouseOver=true'
  Enabled = False
  BlurAmount = 0.009999999776482582
  object FloatAnimation1: TFloatAnimation
    AnimationType = atInOut
    Enabled = True
    Duration = 1.000000000000000000
    Loop = True
    Trigger = 'IsMouseOver=true'
    TriggerInverse = 'IsMouseOver=false'
    StartValue = 0.009999999776482582
    StopValue = 10.000000000000000000
    PropertyName = 'BlurAmount'
  end
end

I set loop = true because if it is false it is not animating it is just suddenly going to end value.

So I set it to true. But now it is looping (as the name described) not just animating once and stopping.

And also I want it to animate from stop value to start value when I leave the mouse (only once). When my mouse leaves or enters, the new animation must start from current value not from the max or min value.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

内心旳酸楚 2024-12-17 19:13:53

触发器并不总是像我期望的那样工作......

你可以这样做:

procedure TForm2.Button1MouseEnter(Sender: TObject);
begin
  BoxBlurEffect1.AnimateFloat('BlurAmount', 10, 1);
end;

procedure TForm2.Button1MouseLeave(Sender: TObject);
begin
  BoxBlurEffect1.AnimateFloat('BlurAmount', 0, 1);
end;

没有 TFloatAnimation:

  object Button1: TButton
    Position.Point = '(264,192)'
    Width = 80.000000000000000000
    Height = 22.000000000000000000
    OnMouseEnter = Button1MouseEnter
    OnMouseLeave = Button1MouseLeave
    TabOrder = 1
    StaysPressed = False
    IsPressed = False
    Text = 'Button1'
    object BoxBlurEffect1: TBoxBlurEffect
      BlurAmount = 0.009999999776482582
    end
  end

Trigger doesn't always work as I expect neither...

You can do it like this:

procedure TForm2.Button1MouseEnter(Sender: TObject);
begin
  BoxBlurEffect1.AnimateFloat('BlurAmount', 10, 1);
end;

procedure TForm2.Button1MouseLeave(Sender: TObject);
begin
  BoxBlurEffect1.AnimateFloat('BlurAmount', 0, 1);
end;

Without TFloatAnimation:

  object Button1: TButton
    Position.Point = '(264,192)'
    Width = 80.000000000000000000
    Height = 22.000000000000000000
    OnMouseEnter = Button1MouseEnter
    OnMouseLeave = Button1MouseLeave
    TabOrder = 1
    StaysPressed = False
    IsPressed = False
    Text = 'Button1'
    object BoxBlurEffect1: TBoxBlurEffect
      BlurAmount = 0.009999999776482582
    end
  end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文