This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

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 "guiinput".
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 "metaclicked" are triggered by a left click on the url. However "guiinput" 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}");
    }
}
Godot version 3.5.stable.mono.official
in Engine by (109 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.