#Mouse Exited Signal Occuring when Mouse Is Overlapping lower UI objects

1 messages · Page 1 of 1 (latest)

limber radish
#

My goal here is to have it so that when you hover over a UI object it pops out and moves to the front (which all works) however when my mouse overlaps with a UI object that is lower (both in space and on the node tree) it triggers the mouse exited signal (which pops the UI back to its resting position). This occurs regardless of mouse filter setting which is baffling. If all are set to pass or all but one are set to ignore the effect is the same.

Anyone know what mechanics are at play here I have been messing with settings and scripts for a good while to no effect.

pallid osprey
limber radish
pallid osprey
limber radish
limber radish
#

weird, I have that currently set up

pallid osprey
#

This is what I have:

#

This is my top Control's script:

extends Control

@onready var texture_rect_3: TextureRect = $TextureRect3
@onready var texture_rect_4: TextureRect = $TextureRect4
@onready var texture_rect_5: TextureRect = $TextureRect5


@onready var ui_objects: Array[TextureRect] = [texture_rect_3, texture_rect_4, texture_rect_5]


signal mouse_is_mine(obj: TextureRect)
signal mouse_is_not_mine

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
    mouse_is_mine.connect(_on_mouse_is_mine)
    mouse_is_not_mine.connect(_on_mouse_is_not_mine)


func _on_mouse_is_not_mine():
    for ui_object in ui_objects:
        ui_object.mouse_filter = Control.MOUSE_FILTER_STOP

func _on_mouse_is_mine(obj_who_took_mouse: TextureRect):
    for ui_object in ui_objects:
        if ui_object != obj_who_took_mouse:
            ui_object.mouse_filter = Control.MOUSE_FILTER_IGNORE
#

This is the TectureRect script:

extends TextureRect


func _on_mouse_entered() -> void:
    print("mouse_entered", self)
    $"../".mouse_is_mine.emit(self)


func _on_mouse_exited() -> void:
    print("mouse_exited", self)
    $"../".mouse_is_not_mine.emit()
#

And this is my setup:

limber radish
#

hmm yeah I have no Idea why this is behaving differently. Technically my UI elements that I am detecting from is itself a control node but I can't imagine that would make a difference here

pallid osprey
#

Tried this to emulate what you have and still works:

extends TextureRect


func _on_mouse_entered() -> void:
    print("mouse_entered", self)
    $"../".mouse_is_mine.emit(self)
    scale.x *= 2


func _on_mouse_exited() -> void:
    print("mouse_exited", self)
    $"../".mouse_is_not_mine.emit()
    scale.x = 1
pallid osprey
#

y

limber radish
#

I have already had this line that really feels like it should be doing the same thing though

    if ui_object == self:
        return
    mouse_filter = MOUSE_FILTER_IGNORE

func on_ui_retracted() -> void:
    mouse_filter = MOUSE_FILTER_STOP```

it does stop the next card from popping out but it dosn't prevent the mouse exited signal from going off as soon as I overlap
#

(both are hooked up to signals that fire as soon as the UI is popped up/down)

pallid osprey
#

I just made each TextureRect to be a childe of a Control node. But if the TextureRect has some offset to its parent Control, then this causes issues. So I made each TextureRect to be Full Rect and now it works.

limber radish
pallid osprey
# limber radish Were you changing the mouse settings for the parent object or the texture rect? ...

Yea, the children need to be updated as well, I think. I changed things to this, and it works:
In the UI object Control node (which has a TextureRect):

func _on_mouse_entered() -> void:
    print("mouse_entered", self)
    $"../".mouse_is_mine.emit(self)
    scale.x *= 2
    z_index = 1000


func _on_mouse_exited() -> void:
    print("mouse_exited", self)
    $"../".mouse_is_not_mine.emit()
    scale.x = 1
    z_index = 0

And in the top Control node:

func _on_mouse_is_not_mine():
    for ui_object in ui_objects:
        ui_object.mouse_filter = Control.MOUSE_FILTER_STOP
        ui_object.get_node("TextureRect").mouse_filter = Control.MOUSE_FILTER_PASS

func _on_mouse_is_mine(obj_who_took_mouse: Control):
    for ui_object in ui_objects:
        if ui_object != obj_who_took_mouse:
            ui_object.mouse_filter = Control.MOUSE_FILTER_IGNORE
            ui_object.get_node("TextureRect").mouse_filter = Control.MOUSE_FILTER_IGNORE
limber radish