Option Button _make_custom_tooltip() issues

when doing that function on a option button, items still have the basic tooltip unlike an item list for example when custom tooltips work just fine

working tooltip on an item list:


and the broken one:

the function works on the button itself, but not its items
does anyone know a fix?
heres the code, its basically the same on both item list and option button (text values are simplified for convinience)

extends OptionButton

func _ready() -> void:
	set_item_text(0, "text0")
	set_item_text(1, "text1")
	set_item_text(2, "text2")
	set_item_text(3, "text3")
	set_item_tooltip(0, "tooltip text0")
	set_item_tooltip(1, "tooltip text1")
	set_item_tooltip(2, "tooltip text2")
	set_item_tooltip(3, "tooltip text3")


func _make_custom_tooltip(for_text: String) -> Object:
	var rich = preload("path to a rich text label scene").instantiate()
	rich.text = for_text
	return rich

thanks in advance

hi, a menu button works by spawning a Popup node, which is a Window. this then contains its own child nodes.
_make_custom_tooltip is an override of a base method of the node.

so you need to override the make_custom_tooltip of each element of the popup for this to work. which is not possible. custom tooltip is also a method of Control and not found in window.

So you need to create a custom Popup scene and spawn it when a button is clicked, instead of using a MenuButton for this to work.
a PopupMenu would also not work because its buttons are built-in to the engine and hard coded on C++.

so:
1 - normal button, maybe toggle.
2 - Popup scene, with a VBoxContainer or ScrollContainer->VBoxContainer.
3 - create a new script and register a new class to create a new node type:

class_name CustomMenuButton
extends Button

func _make_custom_tooltip(for_text : String) -> Object:
	etc

4 - add CustomMenuButtons inside the VBox inside the popup scene.
5 - keep a packedscene to your popup scene. when the button is clicked, spawn it:

func _ready() -> void:
	my_button.pressed.connect(spawn_menu)

func spawn_menu() -> void:
	var tmp : Popup = my_packed_scene.instantiate()
	add_child(tmp)
	tmp.global_position = global_position#you need to calculate where this will go
1 Like

Thanks, with a little bit of tweaking works perfectly!