Half-press button triggering

__Aeon____Aeon__ Posts: 37Member
edited December 2017 in 2D


I have a teeny tiny problem i can't solve with Godot's button's, basically i have a grid of dots which are to be connected by lines via a draw_line() function, this line spawns every time the user clicks over a dot and drags from there, towards where the user's cursor is or their finger touches a phone screen.

And the problem lies herein, the button only issues a pressed signal when a, let's call it, "full click" (pressing the left mouse button and releasing it afterwards) happens, not just when the user hovers, presses and holds the button and drags from there.

Could anyone kindly enlighten me regarding a workaround this?


  • TwistedTwiglegTwistedTwigleg Posts: 4,292Admin

    You could try using the button_down signal. You may need to also use button_up as well if you need to reset stuff when the user isn’t pushing the button.

    I’m not sure if button_down and button_up signals are in Godot 2 or not. If you’re using Godot 3 (or 2 if the signals are there) then that’s what I would suggest looking at as a workaround.

    (We can better tailor our answers if we know which version of Godot you’re using :wink: )

  • __Aeon____Aeon__ Posts: 37Member
    edited December 2017


    Thank you beforehand for your answer. I'm currently using the production/stable version of Godot, v2.1.4, which unfortunately for me does not include those features.

    I have, however, managed to solve the problem by using a script-only singleton that draws the lines on the screen, this singleton include a control variable that is toggled by the enter and exit signals of each individual button, has works so far.

    This sprouted yet another problem, apparently the draw_line() function isn't drawing anything, and i suspect it's related to the z axis setting (it's a 2D game). I have yet to find a solution for this lastest issue, since in Godot 2.1.4, there's no built-in function to set the z axis height of the aforementioned draw_line() function.

    P.S.:Really really waiting for Godot's amazing upcoming 3.0 version to be production ready, it's fantastic to have an MIT licensed game engine at the same level as the "big ones" :wink:
    Hope that Godot's devs add destructible meshes, just like in Unreal Engine 4, at some point in the future with some form of opencl gpu acceleration, especially now that Godot uses bullet physics library :smiley:

  • ZireaelZireael Posts: 96Member

    draw_line() only draws from a _draw() function. And I'm not sure if it'll work from a singleton.
    I've been drawing lines in 2d using the draw_line() and never needed to do anything to z axis height.

  • __Aeon____Aeon__ Posts: 37Member

    Indeed it does, drawing off a script singleton also works, however, in order to set the z axis at which it draws at, it needs to be assigned to a Node2D node.

    This spawned another problem, when i retrieve the line width off a vector with an index, that index was set to null after one iteration of _draw(), i've checked the code multiple times to make sure it wasn't being affected by anything else, i also debugged the script by printing it's value throughout its execution, and it's within the first call of _draw(), that this variable becomes reset for an unknown reason to me, which i'm assuming might be an engine bug. I'm resorting to come up with a different solution involving custom signals instead of having this script singleton remediates the issue.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file