hajimehoshi / ebiten

Ebitengine - A dead simple 2D game engine for Go
https://ebitengine.org
Apache License 2.0
10.41k stars 635 forks source link

a new API to read and write a clipboard content #2726

Open hajimehoshi opened 10 months ago

hajimehoshi commented 10 months ago

Operating System

What feature would you like to be added?

I want a new API to read and write a clipboard content. I have not determined the API yet, but the API should match with Ebitengine's semantics. For example, we might have to restrict reading and writing the content only in Update (https://github.com/hajimehoshi/ebiten/issues/2658).

Why is this needed?

This is useful especially for GUI applications.

There are some existing libraries like https://github.com/golang-design/clipboard, but I'm worried that this uses its own threads and might cause impedance mismatch with Ebitengine's threads. The new API would have to use Ebitengine's internal UI (main) thread.

hajimehoshi commented 3 months ago

Probably I'll add github.com/hajimehoshi/ebitengine/v2/exp/clipboard as an expeirmental package:

package clipboard

func Set([]byte)
func Get() []byte

What about other mime type like images?

EDIT: https://w3c.github.io/clipboard-apis/#mandatory-data-types-x