How to make input stepper UI component

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By FrostyBasil

Hello! I’m new to Godot and coding games in general. I am wondering how I can make an input stepper like the one shown below. I think I can make a counter with incrementor arrows using the documentation tutorials, but I’m not sure how I can combine that with a text input field, so that you can set a number with direct input and clicking the arrows. Thanks in advance!

Edit: thanks for the help!!

input stepper

:bust_in_silhouette: Reply From: exuin

Try modifying a Spinbox.

:bust_in_silhouette: Reply From: scrubswithnosleeves

I would use a LineEdit node and add two buttons for the up and down arrows. Then give the LineEdit a script and have it set_text() to the entered value or the incremented value.

if you want to make it so the user can only input integers, you can use the LineEdit’s text_changed signal, which is emitted after each character inputted, and check if the character is an int. If it is, set_text(), else, set_text() to the previous value.