Widget text not updating
Hi everybody, here what I'm tryng to do: - I click on an object in my level - It appears a menu with three buttons - Clicking the buttons I change the object and set values for two variables - if I go on pause I can see the values of the two variables shown in a box
how I've done:
In the widget "Menu_PopUp_A2" I set different values at the two variables "PA_Scritta" and "PA_Price" depending on which button I'm clicking In the widget "Pause_Menu" I created two text variables "Testo-A" and "Price-A" and bound to two different boxes as content; the value of the two text variables is set at the event construct by the two cast variables "PA_Scritta" and "PA_Price" (converted in text)
What's the problem: Since I'm setting the two text variables at the event construct of the widget, the boxes should be always updated when I add to the viewport the widget, but it works only the first time I add it and then remain fixed on the value of the first time!
Don't mind to the warning of the "cast to" in the "Menu_PopUp_A2" screenshot: in theory I've done all right and practically works perfectly without problems
I'm a real newbie so I'm sorry if my question is dumb but even looking at "parallel" tutorials (like the inventory one) I'm not figuring what is missing or what I'm doing wrong!
asked Dec 02 '15 at 04:48 PM in Blueprint Scripting
AddToViewport does not call the constructor. AddToViewport takes an already existing widget and makes it visible within the HUD.
When the OnClicked(A1_Button), OnClicked(A2_Button), and OnClicked(A3_Button) events execute, the branch from Event Construct is not fired and GetAllActorsOfClass->Get->CastToBP_Ottoman do not execute.
In order for those nodes to execute after OnClicked, you need to place them within the execution branch of those events; but what you should really do is Set the variable once in Event Construct; and then Get the variable value during each OnClicked event.
You're calling RefreshPriceA every tick; you only need to call this when the prices/display changes. Calling every tick is a bit much; especially when you're calling "GetAllWidgetsOfClass" to pull the 0 index widget every frame.
answered Oct 26 '16 at 02:53 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here