gigaherz / Guidebook

Minecraft book API and library
https://www.curseforge.com/minecraft/mc-mods/guidebook
Other
31 stars 16 forks source link

Copy to Clipboard #39

Closed gdarai closed 6 years ago

gdarai commented 6 years ago

Is there a tag for copying some text into the clipboard? If not, please add it.

gigaherz commented 6 years ago

You mean like, when you click on a certain link, it copies to the clipboard?

QbDesu commented 6 years ago

A way to go about implementing such a thing could be implementing some sort of action type system. What i mean is adding an "action"-attribute to link determining how what to do when the link is clicked. And then having some other attribute(s) as options for said action.

<link action="gbook:copy" data="text to copy to clipboard">copy some text to clipboard</link>
<link action="copy" target="element-id">copy text from element to clipboard</link>
<link action="gbook:command" data="spawnpoint">set spawnpoint to current position (requires op)</link>

The handler for said actions would probably just be given the link elements to read out the attributes by itself.

gdarai commented 6 years ago

Yes that is exactly what I am looking for. The issue is that with such capability I would be able to give the player a way to get parts of the book and for example paste them into Open Computer command line... or into Minecraft Console.

gigaherz commented 6 years ago

Hmmm, how about a <code> type tag, that automatically places a "copy" icon next to the text?

I'm thinking like...

Very quick&dirty mockup, just to get the idea: image

I'm still recovering from having been sick lately, but I seem to be quite refreshed right now, so there's a lot I want to do, including easing myself back into modding...

gdarai commented 6 years ago

Don't warry, this is just like work... it will always wait for you. :o) Your idea seems ok. Yes, why not.

gdarai commented 6 years ago

I also noticed, there is "Copy to Clipboard" inside the WEB link. But when you put there some other text, not the "link" but for example a wget command, the link stop working and the "Copy to Clipboard" is not available any more, so even to just make this work would be enough.

gigaherz commented 6 years ago

That dialog is vanilla, I just make use of it.

gigaherz commented 6 years ago

Went the easy route, in the end: book clicking link text copied message (The book doesn't close, but since the message appears behind the book, I closed it myself to show)

The corresponding XML for that link is: <link action="copyText" text="Text to copy to the clipboard">Click me 3</link>

I have a couple more things to look at, but I will be releasing this soon.

gigaherz commented 6 years ago

v2.5.1 is out ans includes links that can copy to clipboard!