Access Widget variables from Blueprint Function Library

Hello everyone,

I’ve got a problem with referencing to an external widget/blueprint, so let me explain what’s going on.

In my project I’ve got this Widget called options_main, containing a combobox and 2 buttons (see image).

I’ve also got a Blueprint Function Library which wants to access the combobox of the options_main Widget. So I’ve tried to make the connection but got an error. So I stripped down to check if the call to ‘options_main’ was valid, and it seems to be invalid…

Another important thing may be how the flow goes, so here it is.

  1. options_main widget had EventConstruct → Call to custom function in the BlueprintFunctionLib
  2. BlueprintFunctionLib tries to call ‘options_main’ (this is where it goes bad)

I hope someone know’s what I’m doing wrong, thanks in advance.

p.s. another weird thing is, when I compile ‘options_main’ the other Blueprint needs to compile again and vice versa. So I can keep compiling them on and on.

I’m confused as to what you are trying to accomplish here.

Blueprint Function Libraries are just collections of functions for you to be able to call from other blueprints. They do not hold information, they just process it.

What is the goal? What are you trying to accomplish? :slight_smile:

I want to fill the combobox from options_main with resolution values from the Blueprint Function Lib (with Rama’s Victory Plugin).

Maybe it’s the wrong approach but I’m used to code in C#/Java, putting everything in seperate classes for readability and easy access.

So from within the options_main widget I’m calling the Fill Combobox with Resolutions function in the Blueprint Lib. And here’s a screenshot of the blueprint function. I think you can read what/how I’m trying to do there :slight_smile:

The Options Main is always invalid. Am I approaching this wrong?

The problem is that you are performing your operations within the blueprint library itself.

Your “Options Main” is a local variable, it only exists in the scope of this function. Due to this reason, your check for it will always return invalid because the object was never created.

If you want to use a blueprint library for the purpose of populating a widget with information, you need to give the widget reference as input to this function. That way, after you call your “Create Widget” method for “Options Menu”, you feed the result to your “Fill combobox with resolutions” function. Give your function a return of widget as well, that way you get the modified widget to add to viewport.

Hope that helps :slight_smile:

Justin, thank you for your response. I do understand why it doesn’t work now, but I do not really understand how to do what you just told me. Do you maybe have an example? That would be a great help.

Thank you so far my friend!

I’ve put together a quick example in one of my projects where I just test various techniques for doing things.

Here, I made a basic widget, the only thing it contains is a combo box (string) that I named ComboBreaker (thumbs up if you know the reference).

I created a small Blueprint Library Function with only one function, it takes in Text and a BlueprintLibraryWidget (what I made above), performs operations on it then returns the updated widget.

I added a horizontal box to my HUD with a button that will spawn one of those widgets and arrange it next to the button for easy inspection.

Here is how I create the widget, then you use the blueprint library function on it to modify it and add it to the horizontal box.

[Result][5]

I don’t know why AnswerHub refuses that picture as an upload like the previous ones, but there’s the result!

The implementation is up to you, this is just a quick overview of how to achieve your goal :slight_smile:

Thank you so much, got it working like a charm =D