Acces text from UMG userwidget from c++
I have my userwidget referenced in my user code like this:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Blueprint Widgets", Meta = (BlueprintProtected = "true")) TSubclassOf< class UUserWidget> EnterPinHUDClass;
But I want to acces a editable text box inside of that userwidget:
How do I do that?
You can define a class derived from UUserWidget that holds an FText value, and then link your text box in UMG to this variable (link it directly to the variable rather than calling a function, it'll save a little on runtime).
After you've defined the class, you can reparent your UMG blueprint to this class under Class Settings.
If you're using an editable text input, you can build a method into the OnTextChanged event that assigns the new value to this variable.
Your other option is to place a pointer to the UEditableText widget (or whichever kind of widget you're using) in your class, and then assign the text box you've created in UMG to this pointer; then you can access the FText value of that text box directly.
Bear in mind that in some of the native text widgets the Text value is protected.
If you already have a UUserWidget subclass defined, you can just add these properties to the existing class.
In order to access the class properties from your array, you'd have to first cast the object to the UMyTextWdiget class.
Sadly, you wont be able to, with current setup. What you can do, however is :
Mark as answer if is helpful.
answered Oct 25 '16 at 11:50 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here