Reference Widget Textbox in C++

I’ve been looking all over for a way to reference a widget textbox inside a HUD coded in C++ and haven’t found anything so if someone could help that would be great.

Hey there,

can you be more precise please? So you are having a Widget made with UMG? and you have a HUD Class in C++
and now you are trying to get your widget via blueprint to your code?

best regards

Yeah that’s what I want and I also want to get the input from a text box in the widgetif that makes sense… I Hope so

ok, if you just want the input (FText or FString or whatever), you can implement a

UFUNCTION(Blueprintcallable, Category =“Epic Category”)
void GetTheTextFromMyWidget(FText inputText);

inside your HUD. When you enter a text in your widget you can save it in a variable. Now it depends on how you create the communication between you widget and your Hud.
You could do it with saying:

Get OwningPlayer → Get HUD → Call GetTheTextFromMyWidget and give it your input as param. However, i would do it with an Event Dispatcher and also not inside a HUD Class. you can check out my Tutorials on Youtube if you like further information bout that.

So if you want to get the Widget reference as well inside c++. First you would need to #include “UserWidget.h”, then add a new Param UUserWidget* inReference to your func. This would mean there can be any Widget given as reference, if you have a selfmade widget im not sure if this is working, you would need to cast to your widget you want to give or give a more precise UserWidget reference at the beginning.

However, inside your blueprint you should now be able to give your widget as a reference to your func.

This is what my brains telling me, so i havnt tested that yet.

best regards

Wow the function works I tried that before and it didn’t, maybe I did something wrong… Anyway thanks a ton

good to hear, i would be happy for a “thumbs up” :slight_smile: