How to Create a Button to Copy the Text to Clipboard?

114 views
Skip to first unread message

James

unread,
Nov 25, 2019, 3:54:01 AM11/25/19
to TiddlyWiki
Hi,

I am curios to create something like this in TW5, so that I no need to highlight and copy the code from my TW5 every time I need to use the code.

Can anyone teach me how to do it?

Is that possible to include Java function in TW5?

Thanks in advance.

Ton Gerner

unread,
Nov 25, 2019, 5:42:13 AM11/25/19
to TiddlyWiki
Hi James,


Cheers,

Ton

James

unread,
Nov 26, 2019, 1:39:57 AM11/26/19
to TiddlyWiki
Thank you Ton.

Would it be possible if we could use the java function in TW5?

TonyM

unread,
Nov 26, 2019, 3:36:41 AM11/26/19
to TiddlyWiki
You would need to write a plugin to include JavaScript unless it can be placed in a bookmarklet (unlikely).

But widgets should be sufficient for what you asked for.

regards
Tony

PMario

unread,
Nov 26, 2019, 4:26:43 AM11/26/19
to tiddl...@googlegroups.com
On Tuesday, November 26, 2019 at 7:39:57 AM UTC+1, James wrote:
Thank you Ton.

Would it be possible if we could use the java function in TW5?

Hi James,

Java and JavaScript are different languages. In the browser we use JavaScript.

If we would allow to include examples as shown in your link, we would expose our users to a security risk. For the same reason Google won't allow it, here in the group, to post executable examples.

So with TW we will need a safe way to allow our users to do "crazy stuff" that wouldn't be allowed otherwise. We expose those functions with socalled: widgets and macros.

The example Ton pointed to is using a tw macro like:

<<copy-to-clipboard "Mary had a little lamb">>

The macro definition contains a predefined button.

A second possibility would be to use the "tm-copy-to-clipboard" tiddlywiki internal message. eg:

<$button message="tm-copy-to-clipboard" param=<<now>>>
Copy date to clipboard
</$button>

Where you can define the text that will be shown. In the example above it will be [Copy date to clipboard] button
and the content will be everything, that is stored as a parameter.

There are a lot of different possibilities to assign something to a parameter eg: The content of an other tiddler.

<$button message="tm-copy-to-clipboard" param={{test-tiddler}}>
Copy the content of "test-tiddler" into the clipboard
</$button>

So if you specify a bit closer, what you really need, I think we are able to tell you, how to do it "The TiddlyWiki Way" ;)

have fun!
mario

PMario

unread,
Nov 26, 2019, 4:28:47 AM11/26/19
to TiddlyWiki
uups,


-m
Reply all
Reply to author
Forward
0 new messages