Control.set_focus_neighbour in tool script isn't being called by the editor

Godot Version



Hey! I think I’ve come across a potential bug in the engine, but before I post a bug report on GitHub I wanted to quickly check with others if I’ve missed something here.

I’ve created a small tool script for my game called LabeledSlider, which extends HBoxContainer, and creates two children on initialisation: an HSlider and a Label. Only the slider is focusable, and by default it works fine, in that when pressing the direction keys it changes focus to the nearest neighbours in that direction.

I have a new requirement in that I need to be able to change the focus neighbours of the slider, which is ‘inside’ the tool script, since setting the focus neighbours of the container does not affect the slider’s neighbours. So I’ve overridden the setter and getter functions so that the slider’s neighbours are essentially forwarded to the container’s:

func get_focus_neighbour(margin: int) -> NodePath:
	var out = _slider.get_focus_neighbour(margin)
	printt("get", name, margin, out)
	return out

func set_focus_neighbour(margin: int, neighbour: NodePath) -> void:
	printt("set", name, margin, neighbour)
	_slider.set_focus_neighbour(margin, neighbour)

The issue I’m having is that while the editor calls get_focus_neighbour when the LabeledSlider is selected in the editor, it doesn’t call set_focus_neighbour when attempting to set the neighbours via the inspector:

Set focus_neighbour_top (NOTE: This is the editor's own message...)
get	opt_audio_master_volume	1	(... and these are messages from the script)
get	opt_audio_master_volume	1	
get	opt_audio_master_volume	1	
get	opt_audio_master_volume	1

This results in the neighbour property always being empty in the inspector. Is this a bug in the engine, or is there a reason that the engine is not calling the setter function?

Many thanks in advance!

UPDATE: I think I know where I’m going wrong now - I tried to replicate the ‘bug’ in Godot 4, and it came up with a warning that overriding native methods is unsupported. So I was trying to do something that only sometimes works, but there was no warning in Godot 3. Looks like I’ll need to find another way to set the slider’s focus neighbours!