Misunderstanding of signals

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

I have a tree that looks like that:

Game
-*something*
-CanvasLayer
--VBoxContainer
---Button

I tried to connect pressed() signal of my Button with a method within Game script. But when I press (and release) button, my on_Button_pressed() method does not do anything…

and my clever face also couldn’t help…

Korinin | 2020-04-27 10:58

Your “question” is lacking a lot of information: Did you connect the signal from the editor or via code? What is that something in your tree? What value have you assigned the “Layer”-property of the CanvasLayer? What does the callback do that shall be executed once the Button is clicked? Are you sure it’s not executed or is it simply not doing what you expect it to do? Are you using a Button, LinkButton or TextureButton?

njamster | 2020-04-27 12:04

Thanks for your reply,

Did you connect the signal from the editor or via code?

From the editor.

What value have you assigned the “Layer”-property of the CanvasLayer?

Oh, wow it has property… 1, just as by default.

Are you sure it’s not executed or is it simply not doing what you expect it to do?

I commented my code and tried to print anything, just like that:

func on_Button_pressed():
    print("pressed")
#   if is_waiting_for_confirmation:
...

There was no output.

Are you using a Button, LinkButton or TextureButton?

Button. I also attached a script to it with one custom function that works just fine.

Your “question” is lacking a lot of information

I apologise if I concealed any important info. I try to keep my question clean of irrelevant things so it could help others with the same problem.

Korinin | 2020-04-27 14:22

Have you tried reconnecting the button from the editor to the game script again.

Asthmar | 2020-04-27 14:53

:bust_in_silhouette: Reply From: Korinin

Hm… As Asthmar suggested, I disconnected and reconnected the signal.
Suddenly, it worked.

No comments.