skokon
Topic Author
Posts: 11
Joined: 09 Jun 2024, 15:55

How to play Storyboard on MouseEnter event?

16 Jun 2024, 09:19

I've been trying to start the storyboard on MouseEnter. It works in C#, but it doesn't work outside Visual Studio, such as in Unreal Engine.

How do I approach this? I want to call a C# event whenever the MouseEnter event is triggered, but when played from Unreal Engine.
 
User avatar
sfernandez
Site Admin
Posts: 3363
Joined: 22 Dec 2011, 19:20

Re: How to play Storyboard on MouseEnter event?

17 Jun 2024, 13:43

I've tested the following xaml in Unreal and when I hover the rectangle it changes the color to green, and goes back to red when moving the mouse out of the rectangle:
<Grid
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
  xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions">
  <Grid.Resources>
    <Storyboard x:Key="animEnter">
      <ColorAnimation To="Lime" Storyboard.TargetName="rect" Storyboard.TargetProperty="Fill.Color"/>
    </Storyboard>
    <Storyboard x:Key="animLeave">
      <ColorAnimation To="Red" Storyboard.TargetName="rect" Storyboard.TargetProperty="Fill.Color"/>
    </Storyboard>
  </Grid.Resources>
  <Rectangle x:Name="rect" Width="300" Height="100" Fill="Red">
    <b:Interaction.Triggers>
      <b:EventTrigger EventName="MouseEnter">
        <b:ControlStoryboardAction Storyboard="{StaticResource animEnter}"/>
      </b:EventTrigger>
      <b:EventTrigger EventName="MouseLeave">
        <b:ControlStoryboardAction Storyboard="{StaticResource animLeave}"/>
      </b:EventTrigger>
    </b:Interaction.Triggers>
  </Rectangle>
</Grid>
Is this what you were trying?

Who is online

Users browsing this forum: No registered users and 6 guests