Hello,
I have a problem with an array that suddenly becomes half empty.
I am creating a keybindings menu that is structured as follows:
- A Widget Blueprint with an image of a keyboard and a Scrollbox.
- Another Widget Blueprint with a Horizontal Box containing a Text and an Input Key Selector.
I want the keys bound by the player to be highlighted on the keyboard image. To achieve this, I created an overlay with a different color for each key on the image.
I created a Struct with the following contents:
- Overlay Object Reference
- Text Variable “KeyNameEng”
- Text Variable “KeyNameGer”
I created a function that generates an array containing these three pieces of information. The array is of the Struct type.
In the Event Construct of the Widget Blueprint, I use a For-Each-Loop to iterate through the array and set the overlay to “Visible” if the text “KeyNameEng” or “KeyNameGer” matches the “Get Key Display Name” of a binding.
This works so far, and when I open the menu, the corresponding keys are highlighted (the overlays are set to “Visible”).
Now, I want to change the overlay of the old key to “Collapsed” and the overlay of the new key to “Visible” when a key is changed.
For this purpose, I created a Blueprint Interface and call an event in the Widget Blueprint with the keyboard when the “On Key Selected Event” from the Input Key Selector is executed in the other Widget Blueprint.
This has been working well so far.
However, now when I try to iterate through the array again with a For-Each-Loop, the object reference to the overlay is empty. Only “KeyNameEng” and “KeyNameGer” are filled. The object reference returns null.
Can you tell me where the error is? Or maybe there is a better solution to achive what I’m trying. Im very sure what im doing is bad practise.
Event Graph
Array Building Function
Input Key Selector Blueprint