I have a simple exercise where I have a row of buttons and when I click on one it copies the texture to a simple TextureRect that follows the mouse. I want to click to place the texture but the event capture I put in place to stopping tracking the mouse uses the original click on the TextureButton.
I tried adding the self.get_tree().set_input_as_handled() but that doesn't work. Also tried .accept_event() on the button after the signal is sent.
I've also blocked further propagation of mouse events using the Mouse/Filter = Stop parameter in the original TextureButton but that also doesn't work. (I guess this is for different nodes, not other parts of the same node's script.
The only thing I got to work is too much of a hack: capture a just_released event on the button then _just_pressed event when I click to drop the TextureRect.
extends Node2D
var iscarry = false
var carryicon : TextureRect
func _ready():
pass
func _process(delta):
if Input.is_action_pressed("quit"):
get_tree().quit()
if iscarry:
if Input.is_action_just_released("drop"):
iscarry = false
print("dropped")
else:
var pos = get_global_mouse_position()
carryicon.set_position(pos)
else:
pass
func _on_batteries_button_up():
carryicon = find_node("floater")
carryicon.texture = $Background/IconRack/batteries.texture_normal
carryicon.visible = true
print("down")
self.get_tree().set_input_as_handled()
iscarry = true