godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.07k stars 69 forks source link

Allow making `[img]` clickable if wrapped within `[url]` in RichTextLabel #5526

Open CsloudX opened 1 year ago

CsloudX commented 1 year ago

Describe the project you are working on

A dictonary app.

Describe the problem or limitation you are having in your project

I was create a dictionary app like this: image

In place 1 and 2, I was used the url tag to detect user's operation: [url=ADD_TO_LIB]ADD_TO_LIB[/url] [url=TTS]TTS[/url]

If I can use img tag in url, it will look much better: [url=ADD_TO_LIB] [img] res://ADD.png [/img][/url] [url=TTS] [img] res://TTS.png [/img] [/url] image

But I found it can't trigger meta click.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Let url tag support img tag in like can write bbcode like this: [url=ADD_TO_LIB] [img] res://ADD.png [/img][/url] [url=TTS] [img] res://TTS.png [/img] [/url] User can click the image to trigger meta click.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

[url=ADD_TO_LIB] [img] res://ADD.png [/img][/url] [url=TTS] [img] res://TTS.png [/img] [/url] image

If this enhancement will not be used often, can it be worked around with a few lines of script?

No, I can't

Is there a reason why this should be core and not an add-on in the asset library?

It's core, can't be add-on.

Zireael07 commented 1 year ago

Url is supposed to be url and not some other strings, BBCode AFAICT doesn't support this (img in url)

TheDuriel commented 1 year ago

[url=https://www.bbcode.org/images/lubeck.jpg][img]https://www.bbcode.org/images/lubeck_small.jpg[/img][/url]

This construct is supported by many BBCode implementations to create a clickable image.

Zireael07 commented 1 year ago

O. TIL.

Calinou commented 1 year ago

Downloading images automatically from URLs may be undesired in certain scenarios, so this shouldn't happen automatically.

Also, chances are this can be implemented using an add-on (RichTextEffect).

TheDuriel commented 1 year ago

That's not at all what was asked here Calinou. My example pulls from BBCode for web usage. In this issues use case, the [img] already only requires support for local resources, and that is all that is desired here.

To be unmistakably clear:

The request is: Allow images and/or text to be used in [url], and in the case of an image, make it so that clicking the image opens the URL the same as if the URL had been in text form.

CsloudX commented 1 year ago

Sorry about my english was not good, thanks everyone, YES, my meaning was Allow making [img] clickable if wrapped within [url] in RichTextLabel

CsloudX commented 1 month ago

It like was supported in Godot4.3 dev6???

AThousandShips commented 1 month ago

It like was supported in Godot4.3 dev6???

If it was implemented then this should be closed and a bug report for the regression should be opened, unless it was accidental that the feature was added

CsloudX commented 1 month ago

I accidentally tested it in 4.3dev6. it like was supported. but I don't know which pull was implement this. and I don't know was officially confirmed support for this feature