How can you get UEditableTextBox in c++ code?

here is WidgetUI.

351705-3.png

and I’m trying to get ChatBox(EditableTextBox) in c++ code

351706-2.png

i made this variable in Header file.

351707-1.png

][3]

this is the cpp code.

if i run this, problem occurs from that Cast.

_chatBox is null.

it’s in BeginPlay()

i think there is no reason _chatBox is null.

what do you think is the problem?

Hello! Can you recheck Cast? Everything other seem ok to me…

Just do this in .h:

UPROPERTY(meta = (BindWidget))
class UEditableTextBox* _chatBox;

It will automatically work without the need to cast anything.

alternatively this worked for me

    	WidgetTree->ForEachWidget( [this]( UWidget* Child )
    	{
    		if (auto* TextBox = Cast<UEditableTextBox>( Child ))
    		{
                           // do something
    		}
    	} );

I found the problem, it was because i ran in listen server with a few clients. clients had no widget assets assigned so i put them all in game instance not to lose them and it worked for me!