Disable signal emitions

Godot Version

Godot 4.4.1.stable

Question

I’m working on updating my inventory system, and I’m implementing a details panel that appears when you click on any item in the inventory. The issue is that the way it’s working at the moment, when you hover over an item, any details panels that are visible at the moment hide, so you don’t have 2 open at once. I am currently doing this by detecting the mouse-entered signal when the player hovers, but this means that any items underneath the details panel are also detected, so as the player navigates the panel, it occasionally hides if the player moves the mouse over an item slot that is covered by the panel. I’ve tried to mitigate this by adding a boolean check, but I’ve since learned that it doesn’t fix the issue because, as soon as the mouse enters the item’s area, it technically isn’t in the details panel’s area as far as Godot is concerned, which means the boolean check fails and doesn’t actually make a difference. Is there a way I can fix this by making only the items that aren’t under the panel emit this signal?

Photos for reference:



Node tree for the inventory item scene:

an abbreviated version of inventory_slot.gd

extends Control

@onready var icon: Sprite2D = $inner_border/icon
@onready var quantity: Label = $inner_border/quantity

@onready var details_pannel: ColorRect = $details_pannel

@onready var item_name: Label = $new_details_pannel/item_name
@onready var item_type: Label = $new_details_pannel/item_type
@onready var item_effect: Label = $new_details_pannel/item_effect
@onready var item_description: Label = $new_details_pannel/item_description
@onready var details_icon: TextureRect = $new_details_pannel/details_icon


@onready var outer_border: ColorRect = $outer_border

@export var texture: Texture2D
@export var equip_slot: String

signal drag_start(slot)
signal drag_end()

var item = null



@onready var new_details_pannel: Control = $new_details_pannel

var on_details_pannel = false
	
func _on_item_button_mouse_entered() -> void:
	_on_long_mouse_exited()
	print('entered item button')
	
	if on_details_pannel == false:
		print('false')
		#print('item: ', item)
		#if item != null:
			#print('valid item')
		outer_border.modulate = Color(1,1,0)
		for i in get_parent().get_children():
			i.new_details_pannel.hide()


func _on_long_mouse_entered() -> void:
	print('entered')
	on_details_pannel = true

func _on_long_mouse_exited() -> void:
	await get_tree().process_frame
	
	var mouse_pos = get_global_mouse_position()
	var mouse_over_related = false
	
	# Check children of details panel
	for child in $new_details_pannel.get_children():
		if child is Control and child.get_global_rect().has_point(mouse_pos):
			mouse_over_related = true
			break
	
	# Check the item button itself (so it counts as "inside" the zone)
	if not mouse_over_related:
		var parent = get_parent()
		for sibling in parent.get_children():
			if sibling == self and sibling.get_global_rect().has_point(mouse_pos):
				mouse_over_related = true
				break
	
	if mouse_over_related:
		return
	
	print("Mouse truly exited details + item area")
	on_details_pannel = false

Blockquote

Set detail panel’s mouse filter to “stop”

1 Like

I just checked, and it is set to stop. Should that prevent it from interacting with items below it?

If you are using boolean logic, you should make the panels (or any ui on the node) mouse filter as pass.

1 Like

Couple of other tips:

  • Try to use containers. Your ui seems perfect for that.
  • Try to have one details panel. And just update the data there depending on which item its showing, rather than creating one details panel for each item. This is also related to your problem:
    Mouse signals propagates from down to up (I think) on node tree. It’s not related to the visibility. So if you have a separate child detail panel for each item, each detail panel will be on top of some other item panel on the node tree. And that’s why you are having the issue.
    If you have only one details panel, you can place it after all of the items. So you won’t have the issue you are having.
1 Like

If I create a separate scene for the details panel and update it like you said, wouldn’t the same bottom-to-top ordering thing still mess with it?

Yes, do that, and instantiate that scene always on top of all slots.

That said, the flag approach should work as well if you implement it properly. As long as a details panel is visible, all slots should be set to ignore the mouse.

1 Like

Do I do that with stop or pass?

Read the descriptions of each mode in the editor tooltip. You’d probably want to set it to “ignore”

1 Like

I saved the branch as a separate scene. Fixed the code that updates the information, and it seems to be working! Thank you!

1 Like