Closing UI resets checkbox/reverts it to unchecked?

I press CAPS LOCK and it draws my new UI. I then check one of the checkboxes and it executes the console command assigned and draws some text on the screen to confirm.
If I CAPS LOCK again, the UI closes… that’s fine. But when I re-open the UI, the checkbox has reverted to unchecked.

I’ve tried adding SetCheckedState -> to “checked” in the blueprint both before and after the functionality of the checkbox but to no avail.

Anyone got any ideas? I’ve probably overlooked something simple.


How are you closing the UI?

Is there any possibility that you are changing the state of the checkbox on ‘Event Construct’? And yes, how are you closing the UI?

Edit: You said that you have tried setting the check state in the blueprint, so how are you accessing the widget? Are you casting?

Would you mind adding Pictures of your Widget and Blueprints, which you use for this?

I think I’m in over my head here. :-/ I’m not a programmer and never dabbled in the UDK before. (Just started playing around with it for the Ark competition.)

Event Construct is not linked to anything. (In the UI graph.)
UI is closed using Remove From Parent (in the FirstPersonCharacter template project blueprint/graph.)
In the graph for the UI, when the OnCheckStateChanged is called I “Set Is Checked” then “Execute Console Command” then “Print Text”.

In this image, in an attempt to figure things out, I made two checkboxes and played around with their output in different ways.
Both “work” but the checkboxes don’t stay checked so I guess I’m closing the UI wrong or I need to read up on this (type?)casting stuff.

My guess is you just spawn a new UI widget when you press caps lock instead of showing/adding the one that you created first.

There’s your problem. Whenever you remove a widget from a parent and then add it back, it creates a new instance of the widget, so everything will be reset. Instead of removing and adding it back to the viewport, add the widget to viewport a single time. For example in the Post Begin Play of your character blueprint. Then whenever you want the Widget to be hidden/disabled, you need to set the widget’s visibility to Hidden (use the Set Visibility node) and Disable the widget (use the Set Is Enabled node). And vice versa for when you want it to be visible/enabled.

Thank you very much for the guidance everyone.

I moved the Create Widget block to be straight after the Begin Play function rather than after the key press event and the checkboxes appear to be working fine now.
(The menu starts on the screen rather than waiting for the keypress so I’ll have to fiddle around with it and figure that out. Disregard. Fixed it :smiley: )

Side-question, if anyone fancies answering it, is the blueprinting system a visual representation of the C++ that’s happening in the background? Or is it something simpler?