For reusability I have made a custom checkbox and saved it as a scene CustomCheckBox.tscn.
It is built like this:
I've added this custom checkbox to my MainScene multiple times.
The problem is that setting the Focus Neighbour Left, Right, Top Bottom values on any of the CustomCheckBox instances in the MainScene doesn't do anything.
I've realized that changing the Focus Neighbour setting on the instance of a CustomCheckBox in the main scene is only passed to the root node of the CustomCheckBox scene which is the CenterContainer in this case.
To fix this I've added a script to the CenterContainer of the CustomCheckBox scene to pass down the values to the checkbox control:
var cb = get_node("CheckBox")
cb.focus_neighbour_left = self.focus_neighbour_left
cb.focus_neighbour_right = self.focus_neighbour_right
cb.focus_neighbour_top = self.focus_neighbour_top
cb.focus_neighbour_bottom = self.focus_neighbour_bottom
This sets the focus neighbour properties, but when there is a focus change in a direction that has a value I get this error:
E 0:00:04.705 getnode: Node not found: ../CustomCheckBoxc.
<C++ Error> Condition "!node" is true. Returned: __null
<C++ Source> scene/main/node.cpp:1381 @ get_node()
I guess the problem has to do with how nodes see eachother's path at runtime in different scenes but I don't know the solution.
Could anyone help?