Detecting Richtextlabel *right* click on url

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

Hi godot,

I know I can connect to RichTextLabel “meta_clicked” signal to detect when a url is clicked. However, this signal seems only triggered on a left click, and I am looking for a solution to detect the right clicks instead (or actually both left and right). Is there a way to do that?

I am having this issue because I would like the label, or its parent, to capture the left click for some other action, by connecting to “gui_input”.
As an alternate solution, it would be Ok if on a left click on the url I could easily prevent this other action.
Both “gui_input” and “meta_clicked” are triggered by a left click on the url. However “gui_input” is triggered first, which makes it difficult to prevent doing the other onclick action when the url is clicked. (at least without writting some quite ugly wrapper.) Do you know some way to prevent this?

Thanks for your attention!

To reproduce (I use Godot 3.5), just add a RichTextLabel with this script attached:

using Godot;
using System;

public class RichTextLabel : Godot.RichTextLabel
{
    public override void _Ready()
    {
        this.BbcodeText = $"Hello [url=urldatastring]displayed link[/url]";
        this.BbcodeEnabled = true;
        this.Connect("meta_clicked", this, nameof(OnMetaClicked));
        this.Connect("gui_input", this, nameof(OnGuiInput));

        this.RectMinSize = new Vector2(300, 300);
    }

    void OnGuiInput(InputEvent e)
    {
        var me = e as InputEventMouseButton;
        if ((me != null))
        {

            var left = me.ButtonIndex == (int)Godot.ButtonList.Left;
            var txt = $"Hello from OnGuiInput.  ";
            txt += left ? "left" : "right";
            txt += " button ";
            txt+= me.Pressed ? "pressed" : "released";
            GD.Print(txt);
        }
    }
    void OnMetaClicked(string url)
    {
        GD.Print($"Hello from OnMetaClicked. data is {url}");
    }
}