Get widget text box by name/id.

I am trying to create a couple different dynamic forms for my game. The forms have a handful of different text boxes for user input. I want to be able to add a function to my base widget to get the value from a text box based on the name of the text box component. However, I can’t seem to find anyway in blueprints to get all the text box components in a widget so I can find the text box by name.

80630-textblockvariable.jpg

You can hold your text block as a variable in your widget by ticking the tickbox indicated. Using that reference it’s just a simple matter of calling GetText on that variable.

1 Like

I am aware I can expose the variable, but I am looking for a more elegant solution. I have a base widget that all my widget forms are inheriting from. I want to be able to add a function to that widget called GetTextBoxValue(string textboxName) that will return the value of a text box in the widget. That way I don’t have to worry about casting to specific widget and can use the base widget function to get a text box value from any of the derived widgets.

If the goal is to avoid casting, then I would recommend implementing an interface. However if you absolutely need to be able to use a string, I’m unsure. I believe you can easily retrieve an array of components of an actor but don’t know about a widget.