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


