I’m trying to use an SEditableTextBox
slate widget, and although it’s easy enough to place one in, I can’t find how to process the OnTextCommitted
event. I can see that it uses a delegate type much like the SButton
takes a delegate function, but how do I deal with the delegate type in my UI class and extract the committed FText
?
The same way?
OnTextCommitted.AddDynamic (this, &ASomeClass::SomeFunction);
Where this you place object you want to call the function, and 2nd argument is a pointer to function that you want to be called
I don’t know if this answer is outdated but the code below works for me
void SomeWidgetClass::Construct(const FArguments& args)
{
TSharedRef VertBox = SNew(SVerticalBox);
ChildSlot
[
VertBox
];
VertBox->AddSlot()
.AutoHeight()
[
+ SHorizontalBox::Slot()
.VAlign(VAlign_Center)
[
SNew(SEditableTextBox)
.OnTextCommitted(FOnTextCommitted::CreateSP(this, &SomeWidgetClass::SetUserName))
]
];
}
void SomeWidgetClass::SetUserName(const FText& NewText, ETextCommit::Type TextType)
{
//This will be called once the user presses enter when using a SEditableTextBox
}
I moved to using UMG rather than pure slate, but thanks for replying, anyway.
old but left unanswered so a possible solution is adding the following class to the inheritance chain in h file:
public TSharedFromThis<Fsomeclass>
so we have :
class Fsomeclass : public TSharedFromThis<Fsomeclass> , .. other inheritances
make sure to declare on the cpp file :
DECLARE_DELEGATE_TwoParams(FOnTextCommitted, const FText&, ETextCommit::Type)
and now it should work.