x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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?

Product Version: UE 4.10
Tags:
more ▼

asked Dec 24 '15 at 10:42 PM in Using UE4

avatar image

Oranjoose
1 1 2 2

(comments are locked)
10|2000 characters needed characters left

3 answers: sort voted first

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

more ▼

answered Feb 12 '16 at 08:00 PM

avatar image

aoakenfoArchiact
217 12 13 23

(comments are locked)
10|2000 characters needed characters left

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.

more ▼

answered Aug 29 '17 at 12:12 AM

avatar image

TheGreenMat
21 1 5

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question