Creating an Integer Spin Box for Widget

Alright, so I recently started creating widgets for my game, and quickly discovered that the spin box component was solely written to be used with a float. Well this looks terrible in my opinion, so many numbers after the decimal. So I set out to find an integer spin box, and to my surprise there was nothing to be found (at least for free, I didn’t check too much of the marketplace). Everyone just tells you to round the float, but this made the slider clunky, sometimes skipping numbers, and it still displays a “.0” at the end of the number. I eventually stumbled upon some Chinese site (UMG Spin Box 和 Text Box 限定输入为 Int_BasicCoder的博客-CSDN博客_spinbox限制输入) that (when translated) claimed to have made an integer spin box, I followed their instructions, and when I was done, I had the exact same float spin box, but now there were two extra integer inputs that seemed to do absolutely nothing.

So my non-programmer brain thought, "hey, what if I just take the regular spin box code, and just change alllll the float values to integer values, that will work. Well I opened the code instantly knew jack about what I was looking at, but I started changing all the places it said “float” to “int32.” Then I built it, got some errors about a duplicate class name, so I changed all the places it said “USpinBox” to “UIntSpinBox”, and then I got errors that there was an incorrect dll linkage (whatever that means).

I googled it and found that it was referring to the build.cs file (the Chinese website had previously instructed me to add “Slate” and “SlateCore” to the “PublicDependancyModuleNames”). I’m barely familiar with APIs, just that they are like a cache of information and things can pull from them. Well lo and behold, the IntSpinBox.h was referencing the UMG_API to find the class IntSpinBox. I thought to myself, “well there isn’t any IntSpinBox in this API, so if I remove it then it will just create a new class here, right?” And my goodness did I not think it would be THAT easy, but it was… it was THAT easy. I rebuilt it and it succeeded, I went into my game and BOOM! there was my integer spin box, displaying integers and working wonders.

TLDR: No one (to my knowledge) has made a public integer spin box, so I am writing to you to tell you I made one (modified UE4’s OG Spin Box) and want to share it with you so you can also have an integer spin box!

The easiest path to implementing this is to go into your game, right click in the content browser, select “New C++ Class”, click the “Show All Classes” check box, type in “Spin Box”, select Spin Box, click “Next”, Change the name to “IntSpinBox”, and then click “Create Class”.

Now navigate to your >game-name<.sln file, it will be in your project folder in windows explorer. Open that sucker, Visual Studios will pop up. Now in your Solution Explorer, navigate to >game-name</Source/.game-name</Private & Public. You will find “IntSpinBox.cpp” in your Private folder and “IntSpinBox.h” in your Public folder. Open them both up and copy and paste the code from the respective files I’ve attached, and change one thing: in the .cpp on line 3, change that directory to be “>your-game-name</Public/IntSpinBox.h”, build your game, and assuming all went well you should now have an integer spin box!

(Sorry if this was long winded, I wrote it as if the reader had no idea what anything programming related was.)

What version of the engine are you using?

I’m using 4.22.2

This is not necessary anymore, as the SpinBox can use integer values by using the following settings :


I am using the latest version of Unreal 4.25 but my “Slider” category is missing most of those options in the details panel of my Spin Box.

Is there something I am missing here?

Check this forum out: UE4.16 (preview 3): UMG- unable to set spinbox delta value - UI - Epic Developer Community Forums

Works for me