Merge branch 'Tryibion-add-button-hover-events'

This commit is contained in:
Wojtek Figat
2022-12-27 20:23:10 +01:00

View File

@@ -71,6 +71,16 @@ namespace FlaxEngine.GUI
/// </summary>
public event Action<Button> ButtonClicked;
/// <summary>
/// Event fired when users mouse enters the control.
/// </summary>
public event Action HoverBegin;
/// <summary>
/// Event fired when users mouse leaves the control.
/// </summary>
public event Action HoverEnd;
/// <summary>
/// Gets or sets the brush used for background drawing.
/// </summary>
@@ -232,6 +242,13 @@ namespace FlaxEngine.GUI
Render2D.DrawText(_font?.GetFont(), TextMaterial, _text, clientRect, textColor, TextAlignment.Center, TextAlignment.Center);
}
/// <inheritdoc />
public override void OnMouseEnter(Float2 location)
{
base.OnMouseEnter(location);
HoverBegin?.Invoke();
}
/// <inheritdoc />
public override void OnMouseLeave()
{
@@ -239,6 +256,8 @@ namespace FlaxEngine.GUI
{
OnPressEnd();
}
HoverEnd?.Invoke();
base.OnMouseLeave();
}