From 241a8bc7643bf033ebc99ac8c2f22d34e590597e Mon Sep 17 00:00:00 2001 From: Saas Date: Sat, 11 Oct 2025 20:30:51 +0200 Subject: [PATCH] add incrementing/ decrementing value boxe's value with arrow keys --- Source/Editor/GUI/Input/ValueBox.cs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Source/Editor/GUI/Input/ValueBox.cs b/Source/Editor/GUI/Input/ValueBox.cs index 674ee0697..db3ae5413 100644 --- a/Source/Editor/GUI/Input/ValueBox.cs +++ b/Source/Editor/GUI/Input/ValueBox.cs @@ -99,6 +99,11 @@ namespace FlaxEditor.GUI.Input /// public event Action SlidingEnd; + /// + /// If enabled, pressing the arrow up or down key increments/ decrements the value. + /// + public bool ArrowKeysIncrement = true; + /// /// Gets or sets the slider speed. Use value 0 to disable and hide slider UI. /// @@ -239,6 +244,27 @@ namespace FlaxEditor.GUI.Input ResetViewOffset(); } + /// + public override bool OnKeyDown(KeyboardKeys key) + { + if (ArrowKeysIncrement && (key == KeyboardKeys.ArrowUp || key == KeyboardKeys.ArrowDown)) + { + bool altDown = Root.GetKey(KeyboardKeys.Alt); + bool shiftDown = Root.GetKey(KeyboardKeys.Shift); + bool controlDown = Root.GetKey(KeyboardKeys.Control); + float deltaValue = altDown ? 0.1f : (shiftDown ? 10f : (controlDown ? 100f : 1)); + float slideDelta = key == KeyboardKeys.ArrowUp ? deltaValue : -deltaValue; + + _startSlideValue = Value; + ApplySliding(slideDelta); + EndSliding(); + Focus(); + return true; + } + + return base.OnKeyDown(key); + } + /// public override bool OnMouseDown(Float2 location, MouseButton button) {