Event Construct

Hello, I have a Widget Blueprint to controll my main menu, I have certain buttons that run on event constructs such as when on clicked I want to move into a different widget then back again, however (You may know this already) but I can not have two event constructs at the same time. If there is way I way to do fix this let me know, if there is also a simpler way of doing this also let me know!

I don’t think i understand what you are asking here. Button events run by themselves on the Event Graph. On press, for instance is a button event that runs on the Event Graph when, well, the button is pressed. The OnConstruct event is just another event that runs on the Event Graph of the widget. This event is called when a widget is first spawned.

What you need to do, if I got it right, is this:

  • When your OnPressed event is called use the “Construct Widget of Class” to create your new widget.
    You can pass the a reference of your current widget so you can make it visible later.
    You might want to create a reference to this new widget, so you dont have to create it every time.

  • Make your current widget visibility to be Hidden (take into account that hidden widgets do not tick), so you can’t call events on it.

  • Handle all the events of your new widget into its own Event Graph (maybe another button pressed to go back to your previous widget).

That doesn’t exists, the “Construct Widget of Class”

I also used this for the button.

Yeah, sorry. Its now called Create Widget (the name then changes depending on the input class).

There is no need for you to use the Event Construct for spawning the new widget, you can do that on the OnClicked event. Something like this:

You are also removing your current widget from the viewport, when you could just hide it. If you want to go to a widget and then come back, this is a way to do it (it will really depend on the use case, but just to get the idea it works fine).

Just a quick edit: The EventConstruct is generally used to initialize variables for the current widget. You can use it the way you are doing it, its just not the way I generally use it. Cheers.

Thank you so much for this, and before I got trying this by myself, may I ask, what are you getting on the first node.

The first node is a reference to the widget i want to display. What it does is checking if its already set, if its not it will create it and save the reference (is not valid execution path); if its valid it ill just make it visible.

I am really sorry, but again, this is all kind of new to me. How do I get a reference to the widget, also “Set Parent Widget” node isn’t a thing, or at least I can’t find it.

Hi there, sorry for the delayed response. No problem, nobody is born knowin.

I will thell you what I did, so you can replicate it in your blueprint.

  1. I created a variable in my original blueprint called “Created Widget”, its class is: “Character Selection Prototype” (that is a class I created, that contains the character selection menu for my game).
  2. In my Character Selection Prototype widget I created a function called “Set parent widget” and a Variable called “Parent widget” (make sure its not a local variable to the function or it will be lost after the function is called, the class must be Widget, since it can be any type of widget). What this function does is just set the value for Parent Widget.
  3. To get the value from Created Widget you just drag and drop it from the variable list and select Get in the context menu. To make it a validate get just right click on it and select: make validate get or something like that (dont remember the exact name).

If you are working with standard widget classes let me know and i can make a mini tutorial for you on how to achieve what you want. Hope this helps.

Don’t doubt on coming back here if you need help.

I will define my main widget as widget1, and my secondary widget which I want to go to as Widget2.

In widget1 you want me do what is in your image above, in widget2 I created then set parent widget function, and the Parent Widget variable, brought it into the blueprint and added validate like so!

60074-screen+shot+2015-09-24+at+3.40.58+pm.png

The variable is non-local, and by “Class” I think you mean variable type, which I set that to a reference to the widget type, also like so

60071-screen+shot+2015-09-24+at+3.33.53+pm.png

Also by “Created Widget” I’m guessing you mean in your case the “Character Selection Prototype” or from the “Create Widget” node, if in this instance we were talking about “Create Widget” in Widget1 I can not drag the Parent Widget variable, into widget1 since its in Widget2 nor can I call “Set Parent Widget” inside widget1.

Sorry if I sound stupid about this, and thank you so much for taking your time and helping me!

Hi DJSKytlz , again, sorry for the delayed response. I made a small sample project so you can see how it can be done :).

I have to apologize since the screenshot i sent you before has indeed an awful mistake. In the set widget parent I’m calling it on self instead of the created widget (self was suposed to be passed as a parameter).

However, here is the example project so you can see it in detail. Just press play yo see it in action. Hope this help you solve your problem! If you have any doubts just come back here.

link text

Hey! I don’t mind the delayed response, no worries! and thank you so much for your time! We got it resolved! I had the problem of calling “Set Parent Widget” function but I just needed to turn off context sensitive :stuck_out_tongue: I’ll go ahead and try this with my other buttons! Thank you!