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) {