Bug with mouse_default_cursor_shape in Rich Text Labels?

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

I’m trying to add RichTextLabels that are clickable with the mouse icon changing to a pointing hand when hovering over the RTL.

With other controls like a regular label or button, I can go to the properties in the editor under Control / Mouse / set Filter to Stop and Default Cursor Shape to Pointing hand and it works fine. Or from code I can set
label.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
and that works fine for regular labels and most other control types that I’ve tested. But neither approach works with a Rich Text Label. I’ve confirmed that I can actually click on the RTL and have events happen, so it’s not as if it’s not detecting mouse events, it just doesn’t modify the cursor like most other control nodes so it seems like probably a bug in the engine.

If so, it should be reproducible by making a new empty project and adding one control node like a regular label with placeholder text and setting Control / Mouse / set Filter to Stop and Default Cursor Shape to Pointing hand, then adding a RichTextLabel and doing the same thing, then playing it to see if the mouse cursor changes.

I’m using Windows 10, and the bug happens in both the Godot editor and when I build an HTML5 game and play it online.

A quick workaround is to add a Control node as a child and make it expand horizontally and vertically to cover the whole text, set the Default Cursor Shape to Pointing Hand and make sure to adjust the Mouse Filter if it doesn’t work.

Bubu | 2021-04-12 09:15

Did you report this bug?

exuin | 2021-04-13 00:57

Thanks, that worked! On the off chance that anyone else is encountering the same problem, the steps I took are:

  1. Add a MarginContainer as a child to the RichTextLabel
  2. Set the MarginContainer Anchors to be 0 for Left and Top, and 1 for Right and Bottom
  3. Set the MarginContainer Margins to all be 0
  4. Set the MarginContainer Mouse settings to Filter: Pass and Default Cursor Shape: Pointing Hand

It took me longer than I’d like to admit to realize that I couldn’t get it to work by changing the Size Flags in the MarginContainer and could only get it to fill the RichTextLabel by changing the Anchors :slight_smile:

plasmid | 2021-04-13 03:05

Not at first, but now that it looks like it really is a bug and not just me not knowing what I’m doing I reported it in issue #47847, thanks for the reminder

plasmid | 2021-04-13 03:09

Glad it worked!

Bubu | 2021-04-13 03:19