UMG - How can i get text in editable text box?

Hi ~ I have created an editable text box in Widget , then user can enter file name , and i will get this name , but i don`t know how.
And i know how to bind other userwidget component :

StartRe->OnClicked.AddDynamic(this, &UCaneraSettingsWidget::OnStartRe);

I have try

LensName->OnTextCommitted.AddDynamic(this, &UCaneraSettingsWidget::GetFileName);

but it dosen`t work , also

FileName = LensName->GetText().ToString();

dosen`t work too.
Hope anyone can teach me , thanks .

  1. Have you indicated all the correct parameters in the GetFileName() function? They should be

    GetFileName(const FText& Text, ETextCommit::Type CommitMethod)

  2. Have you marked GetFileName() as UFUNCTION() ? Without it, AddDynamic will fail.

In any case, here’s my test, and it works:

.h

UPROPERTY(meta = (BindWidget))
UEditableText* EditableTextName;

UFUNCTION()
void Committed(const FText& Text, ETextCommit::Type CommitMethod);

.cpp

bool UTestWidget::Initialize() 
{
    Super::Initialize();

    EditableTextName->OnTextCommitted.AddDynamic(this, &UTestWidget::Committed);

    return true;
}

void UTestWidget::Committed(const FText& Text, ETextCommit::Type CommitMethod) 
{
    FText NewText = Text;
    GEngine->AddOnScreenDebugMessage(-1, 10, FColor::Purple, NewText.ToString());
}

And it prints to screen everything I’ve entered into the Editable Text field.

Certainly, don’t forget to #include “Components/EditableText.h” in the .cpp file and forward declare class UEditableText; in the header.

1 Like

I have an issue with .OnTextCommited . It brings to LINK error. If I use .OnTextChanged (with proper delegate signature, of course) it works.

The LINK error is:

Error : LNK2019: unresolved external symbol “__declspec(dllimport) class UEnum * __cdecl Z_Construct_UEnum_SlateCore_ETextCommit(void)” (_imp?Z_Construct_UEnum_SlateCore_ETextCommit@@YAPEAVUEnum@@XZ) referenced in function “void __cdecl `dynamic initializer for ‘public: static struct UECodeGen_Private::FBytePropertyParams const Z_Construct_UFunction_UFactoryParamsWidget_OnTQtyCommited_Statics::NewProp_CommitMethod’'(void)” (??__E?NewProp_CommitMethod@Z_Construct_UFunction_UFactoryParamsWidget_OnTQtyCommited_Statics@@2UFBytePropertyParams@UECodeGen_Private@@B@@YAXXZ)

Is it that I might miss something in build.cs ?

Found it. Missing dependencies : “Slate”, “SlateCore”;