From 0295e1ca909191de0b2a6d051ebf993624f21b9b Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sat, 30 Nov 2024 23:28:07 +0100 Subject: [PATCH] Add adding keyframes to curve on double-click --- Source/Editor/GUI/CurveEditor.Contents.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Source/Editor/GUI/CurveEditor.Contents.cs b/Source/Editor/GUI/CurveEditor.Contents.cs index 09e30d372..fd51be3fd 100644 --- a/Source/Editor/GUI/CurveEditor.Contents.cs +++ b/Source/Editor/GUI/CurveEditor.Contents.cs @@ -510,6 +510,27 @@ namespace FlaxEditor.GUI return true; } + /// + public override bool OnMouseDoubleClick(Float2 location, MouseButton button) + { + if (base.OnMouseDoubleClick(location, button)) + return true; + + // Add keyframe on double click + var child = GetChildAt(location); + if (child is not KeyframePoint && + child is not TangentPoint && + _editor.KeyframesCount < _editor.MaxKeyframes) + { + var viewRect = _editor._mainPanel.GetClientArea(); + var pos = PointToKeyframes(location, ref viewRect); + _editor.AddKeyframe(pos); + return true; + } + + return false; + } + /// public override bool OnMouseWheel(Float2 location, float delta) {