godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.92k stars 20.17k forks source link

RichTextLabel mouse_exited() event fires by Context Menu when control is Right Clicked #96143

Open wyattbiker opened 2 weeks ago

wyattbiker commented 2 weeks ago

Tested versions

v4.3.stable.official [77dcf97d8]

System information

Linux Kubuntu 24.04 KDE Plasma Version: 5.27.11 KDE Frameworks Version: 5.115.0 Qt Version: 5.15.13 Kernel Version: 6.8.0-39-generic (64-bit) Graphics Platform: X11 Processors: 16 × 12th Gen Intel® Core™ i7-1260P Memory: 15.3 GiB of RAM

Issue description

When enabled, the Context Menu of RichTextLabel fires a mouse_exited event when you right click on the label. In addition, mousing over the Context Menu keeps firing mouse_exited/mouse_entered events. This interferes with the ability to use mouse_exited() with Context Menu at the same time.

However no such event is fired when Context Menu is disabled. Also mouse Left Click has no effect.

image

Here is the code of the single scene above:

extends Control

func _ready():
    # Checked context Menu
    $RichTextLabel.mouse_exited.connect(func():
        $RichTextLabel.add_theme_color_override("default_color",Color.WHITE)
        print(5)
        )   

    $RichTextLabel.mouse_entered.connect(func():
        $RichTextLabel.add_theme_color_override("default_color",Color.RED)
        print(6)
        )       

    # Unchecked Context Menu
    $RichTextLabel2.mouse_exited.connect(func():
        $RichTextLabel2.add_theme_color_override("default_color",Color.WHITE)
        print(7)
        )   

    $RichTextLabel2.mouse_entered.connect(func():
        $RichTextLabel2.add_theme_color_override("default_color",Color.RED)
        print(8)
        )       

Steps to reproduce

Add a RichtextLabel control to a scene with some text. Enable the Context Menu. Add mouse_exited event as above. Right click and event fires even though you did not exit the label. Mouse over Context Menu and the events keep firing.

Minimal reproduction project (MRP)

Attached is the above scene to demo the issue. Please add to an empty project if you wish to try it.

node_2d.zip

bruvzg commented 2 weeks ago

When enabled, the Context Menu of RichTextLabel fires a mouse_exited event when you right click on the label. In addition, mousing over the Context Menu keeps firing mouse_exited/mouse_entered events. This interferes with the ability to use mouse_exited() with Context Menu at the same time.

That's how it is supposed to work, context menu is a separate window and hovering it should emit enter/exit events on both parent window and menu window. Not sure what's the issue.

wyattbiker commented 2 weeks ago

As an example I have a custom RichTextLabel tooltip being displayed. The tooltip closes when you mouse exit from it, Also the tooltip allows the user to select text and right click to get the context menu. That particular action closes the tooltip, before the user selects from the Context Menu

Attached is a simple demo. Tooltip is displayed when you hover over the main control. When you hover over the tooltip and then away the tooltip closes. If you display tooltip again and then select text ad Right Click the tooltip closes. This should not be happening, I don't know why it needs to emit a mouse exited since the mouse did not exit.

P.S. This is why the Editor Inspector does not have a Context menu enabled on it's own property tooltips. Whoever coded that had an issue but decided to just allow select text and then use CTRL+C

Attached is a simple demo to show the issue. tooltip_demo.zip

Here is a screencast:

https://github.com/user-attachments/assets/d930fb3a-d2fe-4ef9-8556-0e38fd98afb0