Pressing Down a TextureButton, Label increments

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

I have a TextureButton “buy” that signals to a script and a Label “quantity”:
Is it possible for the user to click and hold the mouse button on the TextureButton, and while holding down the Label does a label = label + 1?

Here’s what I have so far:

var temp_quantity = 0

func _on_buy_pressed():
 temp_quantity = temp_quantity + 1
 label_quantity.set_text(str(temp_quantity))

I want the label_quantity to keep increasing in number the longer the user has the texturebutton clicked/pressed. Is it possible to do this?

Thanks!

:bust_in_silhouette: Reply From: hilfazer

For tasks like this Godot has a SpinBox node. It allows increasing as well as decreasing. It emits a signal when value changes.

It also has “Custom Icons” property for its buttons. Didn’t use that but it looks like you can add your textures there.

You may need to resize it after adding to scene to see the buttons.