godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

Add a way to detect whether the clipboard can be used in HTML5 #5430

Open bend-n opened 2 years ago

bend-n commented 2 years ago

Describe the project you are working on

A multiplayer chess project in which you can copy PGNs to the clipboard.

Describe the problem or limitation you are having in your project

On chrome, if your project is embedded inside a iframe, it will not have access to the clipboard api by default[1].

I need to know if that is the case, so I can provide a better way to write down the pgn.

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

A feature tag if the clipboard is usable.

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

if OS.has_feature("clipboard"):
  OS.clipboard = "1. e4"
else:
  draw_text("1. e4")

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

Yes, you can do a JavaScript.eval, but its not very easy, and isn't cross platform.

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

core.

dalexeev commented 2 years ago

It seems to me that this should be an OS method (like OS.is_userfs_persistent) and not a feature tag, since this trait is unlikely to be used often for overriding settings and the like.

bend-n commented 2 years ago

@YuriSizov Is it platform dependent? Are not there other platforms in which the clipboard is inaccessible?

YuriSizov commented 2 years ago

As far as I know, this is only a major limitation on web due to web's security concerns. But more importantly, this is what your proposal tells us.

Mickeon commented 2 years ago

I agree on the sentiment but not on the solution. The default tags included in the engine are based on what they're built for. "clipboard" doesn't fit. It would be better as a function, so that it may be properly described, as well.