Show hover text

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By pronax

I have a program that dynamically creates a chart. How can I make it so that when I press / hover, the text (value of a given point) is shown above a given point?

This is what I want to do about.

I already have a function responsible for clicking on a point, but so far it only displays text in the console.

func app_in_arr():
	but_text[points_arr.size()-1].connect("pressed", self, "btn_press",[but_text[points_arr.size()-1]])
func btn_press(_button):
	print("correct value")
func add_btn():
	var new_button =; 
	add_child(new_button); = str(points_arr.size())
	new_button.rect_size = Vector2(20,20); 
	new_button.rect_global_position = Vector2(x+50.36,(-y/now_del)+440.41);
	new_button.texture_normal = load("res://sprites/empty_texture.png")
	new_button.pause_mode = Node.PAUSE_MODE_PROCESS
	return new_button

I need, instead of the print, the value to be displayed as in the screenshot above.

Could you dynamically place a Label at each of those points, and when the user moves their cursor over the point, the Label is shown? Failing that, maybe the points have tooltips? Control nodes have the hint_tooltip property, so maybe you could use that?

Ertain | 2020-05-25 04:11

Thank. I did not find a way to connect hint_tooltip, so I decided to just create a label in the same way as buttons. The only thing I don’t understand is how to read the hover over the button? Only pressed works.

pronax | 2020-05-25 06:05

:bust_in_silhouette: Reply From: njamster

I did not find a way to connect hint_tooltip

You don’t need to connect anything:

func btn_press(_button):
    hint_tooltip = "correct value"

how to read the hover over the button?

Connect to the mouse_entered|exited-signals:

func app_in_arr():
    # TODO: add the label node?
    but_text[points_arr.size()-1].connect("mouse_entered", self, "_on_btn_mouse_entered", [but_text[points_arr.size()-1]])
    but_text[points_arr.size()-1].connect("mouse_exited", self, "_on_btn_mouse_exited", [but_text[points_arr.size()-1]])

func _on_btn_mouse_entered():

func _on_btn_mouse_exited():