Download

setting visibility of a widget from another widgets button?

Dont know why this is but i cant seem to get a button in one widget to set the visibility of another widget. but i can bind a key to set its visibility. the widget im trying to set visible has a canvas panel and in the canvas panel a vertical box that is set to hidden. now it works fine if i do it from my characters blueprint but not from the button it self im calling the right variable but it just wont work.

That’s pretty easy. Let’s say you want widget1 to hide widget2.
In widget1 you’d create a variable of type widget2. Then, when widget2 is created with “Create widget”, cast to widget1 and set the variable in widget1 as the return value of the “Create widget” node.
Then from that variable in widget1 you will be able to use it to set its visibility to whatever you want.

yeah done that still dont work everything is set up so that i got a bool that will check if the menu is active. i have tried casting i have tried making a variable just for that inventory but i cant get the inventory to open an close. the input key i got set up works the same way you just subscribed. but instead of a widget im calling it from the character blueprint and that one works fine. but when i try the same setup from a widget with another button it dont work. and i get errors saying access none for every time i press the button.

als o i should add that the widget it self is already created. its the vertical box with in that widget that im trying to set the visibility on. in other words the widget it self is already added to view port.

You are probably not setting up the variable properly if it says “Accessed None” or you didn’t cast the variable properly.

You could just create a visibility binding (for the object you want to change the visibility of) in your details panel, and promote its input to a variable.
Then, set that variable when your button is pressed.

if im using the same variable to allow the i key to open the inventory and it works fine. then doing the same thing from the on click event for the button should pull the same results so the problem is that even if i do everything exactly the same as the input key call it dosent open and close the menu. it does nothing and i get accessed none for the error. i know the variable that i have it bound to works since its also being used for the input key event and calls the menu fine. so the issues lies with why cant the widget im calling from access the inventory widget. now im not trying to set the whole widget visible just the menu inside the other widget the canvas panel that it resides in is set to hit test self invisible. like any other canvas.

So after deleting the widget i was using and remaking it i can get the button to work problem is now if i use the button it calls a second copy of the inventory the one i call with the i key works fine and shows the items in the inventory but when i call it with the button it calls a completely new inventory so even if its open a new one pops up… so im a little confused.

You really should read at least a bit of documentation before trying to blueprint. If you don’t learn enough and end up making really messy blueprints for a long time, you will regret it.

xendran if im already checking to see if something is visible or not and the menu is already up then it should work in the same aspect so i dont see what your getting at with your comment there i use a branch before i use flipflop to open close the menu. if i hit “I” and my inventory comes up it should also work to were if i hit the button it should also close it. but thats not the case instead its creating a duplicate. i dont see how im creating a duplicate when the menu is already there.

You didn’t indicate at all that you had actually tried using branch/flipflops.
At this point, you’re going to have to show us the nodes because a correctly set up branch or flip flop should work just fine (and i have done it many times in my HUD/Menu system).

If you have your other widget within another widget you can also use the “Add Child” option instead of creating a new widget which might cause problems.

ok heres some pics first pic here is of the inventory widget on click event

this second one is on the characters bp for the input event that calls the menu

and last this is what they look like when you use both in game there is an animation connected to the menu thats why they are not lined up but thsi allows me to show you they do duplicate.

What’s up with those booleans? You seem to have two both for being in the menu, rather than one for being in menu and one for being in an animation.
I also recommend collapsing an inventory, not hiding it.
Here’s an example of how i set up my item hotkey slots. I dont actually set visibility here, but it gives you an idea of how i control the flow:

ba6f10f850.png

Also, i recommend having the functionality of the action inside of UMG, not your character blueprint. You should create an event in the UMG graph and then simply call that event from your character blueprint.
When i said bind the visibility, i meant using actual bind nodes like this:

Not exactly the same of course since different games have different UI setups, but it should give you some ideas.

ok ill try that tomorrow and see if i can get it to work thanks for the info. :smiley:

binding isnt working either i just keep getting duplicate menus so i decided to just take the buttons out and go with keybinds. would have liked to have given that option to players but i cant seem to stop the duplicate windows from appearing no matter how i set it up. worse part is that one of them acts as a inventory while the other is just a blank duplicate. now for the head ache of trying to implement drag and drop with umg. thanks Xendran for the ideas and help! :smiley:

But if you are getting a duplicate of your inventory must be because you are creating another widget from the same class.

Also, in your pictures you are not showing us the place you are creating the widgets from. If you are getting two widgets of the same is because you have set both variables as the same widget reference.
Plus, I’d recommend you not creating the widgets and then just set their visibility on/off, because when they are hidden they are still using up memory space. It is better to create the widget in the button press itself and use Remove from Parent node in the next button press to remove it.

yeah but wouldnt that wipe my inventory of all its items? cause i was thinking the same thing but i was afraid it would wipe my items all together. and at this point i already have the widget set up to have everything go through one widget. meaning no child widgets except my slots. also the widget it self gets created once. unless switching between levels would cause teh same effect if i am creating the widget in the character blueprint

hate to even think about commenting on this but…

  1. those N flip/flops expect to actually flip then flop you can’t control them from another BP. and I don’t see where you are setting the focus to the widget only to do so (I don’t think you need to use them like that, probably best to dump them)
  2. you have 2 Boolean values in your BPs -> Inventory Active & Menu Open but you don’t show where you are using them to actually control flow of what is shown & when
  3. you don’t show where you set those (blue) Menu Objects, just creating a variable of that class doesn’t necessarily do anything if you don’t set them
  4. you need to show where you actually use Create Widget and create the widget & where you set the widget objects at

From what little I can see you have actually created 2 different widgets somewhere and expect them to act like one.
Post ScreenShots of where you create & set the widget objects & also show where you set and use those variables.
And explain how you expect those Booleans to control flow if you aren’t using them

on a side note: I really like your graphics & setup of your Inventory & UI -> looks really good! :slight_smile:

ayretek the inventory i self is done by the new ue4 tutorial i just did exactly what they did. the way they do it is the inventory active bool is set to the enabled bind on the vertical box that houses the inventory with enabled unchecked. the inventory it self is set to hidden. in the my character blueprint following the tut they do a event begin play and create the widget there and do a key bind there as well to hide / show the inventory. all inventory mechanics are set up in the widget blueprint. the menu open bools are there for when i add in a cross hair there for later use to when i add in the cross hairs i can say wither or not to show the cross hairs. the “blue Menu” objects are all set up in the inventory widget i.e. ( to call the panel to make visible you have to get your inventory widget then get the inventory panel in order to set its visibility.) so even though im only creating the widget once its still duplicating when i hide/show it with a different button other than the keypress

sidenote: thanks :smiley:

this series here https://docs.unrealengine.com/latest/INT/Videos/Player/index.html?series=PLZlv_N0_O1gZo6zXTHGGSH8gxaA7a_zCt

k, thought I would try to help, but that’s a 2 hour tutorial and I like helping people etc. but I’m not going thru that tutorial right now and if you have followed the tutorial why doesn’t your BP work?

again I haven’t followed or done the tutorial
but what my point was that you need to look & follow your flow thru your BPs, if you are trying to control that one widget from 2 different BPs or places you need to have complete control.
use a control Boolean that both places can access not a local one unless you completely control it’s use.
another words when you go into that inventory it needs focus & control over that key press and the click, you can’t do them separately without the one knowing what the other is doing there is a lot of ways to set up widgets & use them but you can’t just throw it all together & expect it to work either.
you need to look at this if you are creating your own widget & using it with that tutorial
https://docs.unrealengine.com/latest/INT/Engine/UMG/UserGuide/CreatingWidgets/index.html

that’s not a visibility problem you have there, you have 2 separate instances of the same widget