Button_up Signal doesn't trigger when the button is pressed for the first time

Godot Version

4.3

Question

I have connected the button_up and button_down signals to 2 functions that would change a “is_being_held” variable to determine whether the mouse is being held and I use that with some logic under a _process function to make draggable items. However, when I press the button for the first time after starting the game, the button_down signal works, however the button_up doesn’t work so it thinks it’s still being held down until I click again. However on the 2nd time and onwards it works perfectly.

Hi,

It is going to be very difficult to offer any help without any code to look at. My guess would be that the button up signal works fine, but your code is not registering it, potentially due to a flag you have set, or something else not yet enabled within your code.

Post some code and I am sure someone will be able to help further.

2 Likes


Sorry, I forgot to provide the code but there are no flags under mouse_up. I do have flags under mouse down but mouse down already works fine, but mouse up doesn’t work despite the signal being connected properly + there being no flags

Also, the issue only has to do with line 27 pretty much, when I instance the scene with this script, when I click it for the first time the mouse_up signal doesn’t fire. I have 100% confirmed that it just doesn’t fire. However when I press it again, it does start to fire as intended.

another thing to add, when I run this scene alone, it works as intended. However, when I instance this scene under a HFlowContainer(like in the screenshot below) I start to have the issue I just mentioned.

@gk98s
Completely unrelated to your question, make sure you don’t send your code as a screenshot. Send it via formatting text you pasted.

Here’s how: (Not mine, but it works)

2 Likes

Sorry, I also wanted to include the node tree. Also, I am guessing that this issue doesn’t really have anything to do with the code. Since when I launch the item scene alone(the draggable scene with the button as the child) it works perfectly. Whereas when I launch the inventory scene and instance the item scene, it has this strange issue where I start holding down, it fires the mouse_down signal, but after I stop holding down it doesn’t fire the mouse_up signal, but this only happens once per instance and when I start clicking it more, it works perfectly fine.

Could there be a problem with the way I set up my inventory scene?

Okay this is very weird but I literally changed nothing, but the issue went away. Could this have been an engine bug? I have literally not changed anything in my code or any properties of any nodes.

@gk98s
For node trees, you can either screenshot your scene tree it if it’s small enough.

Or better yet, use the built-in functions:

  • print_tree()
  • print_tree_pretty()
    Then, copy/paste them in your post.