slate SNumericBoxEntry bug?

Hello.

I’ve been working with slate now for a few years and only recently have delved into the SNumericEntryBox widget and it doesn’t appear to be working for me? I have search the engine code for uses of it and can’t understand why my implementation isn’t working.

The widget is created at runtime, but I am unable to commit any numbers to the text box. I have even placed some breakpoints in the ValueChanged and ValueCommitted event handlers in the SNumerEntryBox source code and it seems that after the text is committed (via hitting the return key) the Commit event is fired, but then another value change event setting the value back to 0 is called. I’m also trying to use SVectorInputBox and SRotatorInputBox, which use the SNumericEntryBox.

All of this has been tested using a fresh project.

Does anyone have any incite into what is happening here? I’ve spent over a full day just trying to figure this out.

Video: http://www.nervenet.net/videos/NumericEntryBoxBug.mp4

Project/Plugin Files: http://www.nervenet.net/videos/NumericPluginProject.rar



void STestWindow::Construct(const FArguments& InArgs)
{
    SWindow::Construct(SWindow::FArguments()
        .Title(LOCTEXT("TestWindowTitleLabel", "Test Window"))
        .CreateTitleBar(true)
        .bDragAnywhere(true)
        .FocusWhenFirstShown(true)
        .HasCloseButton(true)
        .SupportsMaximize(false)
        .SupportsMinimize(true)
        .IsInitiallyMaximized(false)
        .IsInitiallyMinimized(false)
        .AutoCenter(EAutoCenter::PrimaryWorkArea)
        .SizingRule(ESizingRule::Autosized)
        .MinWidth(360)
        .MinHeight(100)
        
            SNew(SVerticalBox)
            + SVerticalBox::Slot()
            .AutoHeight().HAlign(HAlign_Fill).VAlign(VAlign_Center).Padding(1.0f)
            
                SNew(SNumericEntryBox)
                .Value(50.0f)
            ]
            + SVerticalBox::Slot()
            .AutoHeight().HAlign(HAlign_Fill).VAlign(VAlign_Center).Padding(1.0f)
            
                SNew(SVectorInputBox)
                .bColorAxisLabels(true)
                .X(0.0f).Y(0.0f).Z(0.0f)
            ]
            + SVerticalBox::Slot()
            .AutoHeight().HAlign(HAlign_Fill).VAlign(VAlign_Center).Padding(1.0f)
            
                SNew(SRotatorInputBox)
                .bColorAxisLabels(true)
                .Roll(0.0f).Pitch(0.0f).Yaw(0.0f)
            ]
            + SVerticalBox::Slot()
            .AutoHeight().HAlign(HAlign_Fill).VAlign(VAlign_Center).Padding(1.0f)
            
                SNew(SRotatorInputBox)
                .AllowSpin(true)
                .bColorAxisLabels(true)
                .Roll(0.0f).Pitch(0.0f).Yaw(0.0f)
            ]
        ]
    );
}


need to create value-handling functions
1 function to display the value
1 function to change values

.h file



TOptional GetTransformDelta() const;            // display this value
void TransformDeltaCommited(float newValue, ETextCommit::Type CommitType);   // set value when keyboard input

float SomeoneFloat;    // this value is displayed in SNumericEntryBox



.cpp



SAssignNew(numOffset, SNumericEntryBox)                                     //Ctreate SNumericEntryBox
.Value(this, &FInstancePluginEdModeToolkit::GetTransformDelta)              // display this value
.OnValueCommitted(this, &FInstancePluginEdModeToolkit::OffsetCommited)  // set value when keyboard input

...
// get value to display in SNumericEntryBox
TOptional FInstancePluginEdModeToolkit::GetTransformDelta(EAxis::Type axis) const
{
    return SomeoneFloat;
}

// Set Value
void FInstancePluginEdModeToolkit::TransformDeltaCommited(float newValue, ETextCommit::Type CommitType)
{
      SomeoneFloat = newValue;
}

 

result Imgur: The magic of the Internet

Thanks for the quick reply.

You are exactly right. Seems that the value has to be bound to a function for things to work. I thought I could get away with just assigning a value to the widget and I would be able to still change it and retrieve it again using the exposed variable through SAssignNew and set it myself, but the way the SNumericEntryBox works, it requires the value to be bound to a function.

Thank you again. Much love to you.

How does this work for Min and Max Value. I am able to successfully commit the value and display it but it doesn’t abide to min and max constraints that I have set. It just sets what ever number I choose it to be.

Try to limit the value in TransformDeltaCommited().
Or use some other widget instead of SNumericEntryBox.
It is possible not to use TransformDeltaCommited(), but I do not know any other method.