Integer spin box? Other text field?

Simple question: is there a setting to make spin boxes only permit integers?

I’m looking to make a text field that only takes integers.

I know I can do a quick absolute value in the on commit event, but it still displays the point 0 since it is a float.

Any good solution here?

I don’t believe the spin box supports integer display. A compromise is to set the ‘slider delta’ to 1. However, it will still display a trailing .0

You can do this by creating your own version of USpinBox in C++. Start by creating a C++ class with base UWidget, and copy over the contents of USpinBox.h and USpinBox.cpp to your respective new files. Then, change a few key areas of the spin box code to use int32 instead of float. Some of these key areas include the following.

The dynamic multicast delegates:


    DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnIntSpinBoxValueChangedEvent, int32, InValue);
    	DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnIntSpinBoxValueCommittedEvent, int32, InValue, ETextCommit::Type, CommitMethod);
    	DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnIntSpinBoxBeginSliderMovement);

The handle functions:

void HandleOnValueChanged(int32 InValue);
	void HandleOnValueCommitted(int32 InValue, ETextCommit::Type CommitMethod);
	void HandleOnBeginSliderMovement();
	void HandleOnEndSliderMovement(int32 InValue);

The shared pointer:

TSharedPtr<SSpinBox<int32>> MySpinBox;

A few more similar changes must be made in the .cpp file, but they all come down to changing floats to int32 where needed. Finally, make sure you set your spin box delta to 1.

Hey! So I had the same problem and solved it by modifying the original spin box! Hope this helps!

https://forums.unrealengine.com/development-discussion/content-creation/1641116-creating-an-integer-spin-box-for-widget

in… 5.3 fractional part is hidden if both max and min fractional digits are set to zero