Fix color editing control to properly handle mouse event

#1782
This commit is contained in:
Wojtek Figat
2023-11-10 10:20:21 +01:00
parent 39a5b8e635
commit 7d70a15034

View File

@@ -14,6 +14,8 @@ namespace FlaxEditor.GUI.Input
[HideInEditor]
public class ColorValueBox : Control
{
private bool _isMouseDown;
/// <summary>
/// Delegate function used for the color picker events handling.
/// </summary>
@@ -134,11 +136,22 @@ namespace FlaxEditor.GUI.Input
Render2D.DrawRectangle(r, IsMouseOver || IsNavFocused ? style.BackgroundSelected : Color.Black);
}
/// <inheritdoc />
public override bool OnMouseDown(Float2 location, MouseButton button)
{
_isMouseDown = true;
return base.OnMouseDown(location, button);
}
/// <inheritdoc />
public override bool OnMouseUp(Float2 location, MouseButton button)
{
Focus();
OnSubmit();
if (_isMouseDown)
{
_isMouseDown = false;
Focus();
OnSubmit();
}
return true;
}