help with _unhandled_input : Clicking All elements

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

Hello there.

I have a building placed on the map that, when you clic on it, the UI with it informatios show :

func _on_tower_input_event(viewport, event, shape_idx):
if (event is InputEventMouseButton && event.pressed):
	Globals.main_game_node.tower_ui(self) #Open the UI of the tower
	if event.position.y > 450:
		#TOP position
		get_node("/root/playing/ui/tower").rect_global_position.y = 100
	else:
		#BOTTOM POSITION
		get_node("/root/playing/ui/tower").rect_global_position.y = 500

I also have a spell, which when i clic, detect enemies on the map and apply effects.
Problem is that when the spell is placed on top of the building with the cursor, the building’s UI open as well.
I know I have to use unhandled input, but I can t figure out how to apply it here.
And finding examples online, so far hasn’t been a real success…

This is the event input for the spell as well:

if spell_mode == true and build_mode == false:
	#add pixel verification
	var mouse_position = get_global_mouse_position()
	if mouse_position.y < 685 and mouse_position.y > 102 and mouse_position.x < 467 and mouse_position.x > 15:
	
		if event is InputEventMouseButton:
			var pos = event.position
			if event.pressed:
				#clic - nothing, we apply the spell on release.
				spell_1 = load("res://spells/spell_" + str(selected_spell) + "/spell.tscn")
				spell_instances = spell_1.instance()
				self.add_child(spell_instances)
				spell_instances.active = 1 #So that when we first instance it to get info for button it doesnt "start"
				spell_instances.global_position = mouse_position
				spell_instances.start(self)
				reset_spell_timer(timer_reset, spell_instances.spell_cd)
				
				#close spell UI
				close_all_ui("close_all")
				pass
				
			else: 
				#release click
				#instance the spell selected
				pass
	pass

anyone able to show me how to implement/fix this please ?
So that I can see/learn and apply to the rest of my UI elements ^^

Thank you very much in advance

:bust_in_silhouette: Reply From: quizzcode

set_input_as_handled()