Cool feature request - click to copy

84 views
Skip to first unread message

TonyM

unread,
Jul 19, 2012, 1:14:28 AM7/19/12
to tiddly...@googlegroups.com
When working away with multiple copies and pastes part of my work flow I find the single copy/paste buffer frustrating.

I found this http://www.htmlgoodies.com/beyond/javascript/article.php/3458851/Click-Its-Copied.htm great tip but it does not work in FireFox (Plenty of advice on line on how to address that).

The skills required to build a script or plugin tiddlywiki is beyond me so I am posting here to see if one of you gurus could have a go. It looks to me a simple proposition for a great feature.

I would love to be able to have a tiddlywiki macro such as <<pasteBox>> which displays a text entry box (so I can past snippets into or set a default value) and a Button labeled "Copy to Clipboard" which would copy the text in the text box into the windows (Win7) clipboard. Allowing multiples of this in a single tiddler would be great, perhaps it could have the format <<pasteBox fieldname>>

This would allow me to create a tiddler of reusable snippets that can be open on one screen with the cut and paste work on another. Only one click would be required each time I needed to get something else into the clipboard to paste into other apps or browser windows.

I would love to see what you think !

TonyM

SpiderX

unread,
Jul 19, 2012, 3:36:59 PM7/19/12
to tiddly...@googlegroups.com
Seems neat. I am comfortable enough with CTRL-C and CTRL-V that I don't need it. However, it's really easy to create a tiddlywiki macro. See the documentation below.

TonyM

unread,
Jul 20, 2012, 2:03:09 AM7/20/12
to tiddly...@googlegroups.com
Thanks SpiderX

Do you think the feature at http://www.htmlgoodies.com/beyond/javascript/article.php/3458851/Click-Its-Copied.htm can be done this way ?

Regards
Tony

SpiderX

unread,
Jul 20, 2012, 1:27:12 PM7/20/12
to tiddly...@googlegroups.com
Sure, but that only works for IE, maybe some versions of Firefox. Clipboard support is not a W3C standard.

TonyM

unread,
Jul 31, 2012, 11:30:15 PM7/31/12
to tiddly...@googlegroups.com
Bump

Anyone with the skills to help me do this ?

I just dont know enough to convert between a Java Script solution and TiddlyWiki Integration.

See here for a complete and documented solution that works in firefox http://www.htmlgoodies.com/beyond/javascript/article.php/3458851/Click-Its-Copied.htm can be done this way ?

Thanks
Tony

Eric Shulman

unread,
Aug 1, 2012, 2:49:56 AM8/1/12
to TiddlyWikiDev
> Bump
>
> Anyone with the skills to help me do this ?
>
> I just dont know enough to convert between a Java Script solution and
> TiddlyWiki Integration.
>
> See here for a complete and documented solution that works in firefoxhttp://www.htmlgoodies.com/beyond/javascript/article.php/3458851/Clic...be done this way ?

The script they describe is actually *not* all that robust. I've
actually got a function that already written that copies an entire TW
document to the clipboard:
http://www.TiddlyTools.com/#SaveToClipboard
Embedded in that code is a function, "copy(out)" that copies specified
output text to the clipboard, and will work for many versions of FF,
IE, Chrome, Safari, etc. For your purposes, you could borrow this
function and write the following in a tiddler called PasteBox:

[[PasteBox]]
-----------------------------
<html><nowiki>
<textarea rows="10" style="width:100%" onfocus="this.select()"></
textarea>
<input type="button" value="copy to clipboard" onclick="
function copy(out) {
if(window.Components) { // FIREFOX

netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var id='@mozilla.org/widget/clipboardhelper;1';
var
clip=Components.classes[id].getService(Components.interfaces.nsIClipboardHelper);
clip.copyString(out);
} else if(window.clipboardData) { // IE
window.clipboardData.setData('text',out);
} else if(document.execCommand) { // CHROME, SAFARI, IE6
var ta=document.createElement('textarea');
ta.style.position='absolute';
ta.style.left='-100%';
document.body.appendChild(ta);
ta.value=out; ta.select();
document.execCommand('Copy',false,null);
document.body.removeChild(ta);
} else throw('cannot access clipboard');
}
var ta=this.parentNode.getElementsByTagName('textarea')[0];
try { copy(ta.value); displayMessage(ta.value.length+' bytes copied to
clipboard'); }
catch(e) { displayMessage(e.description?e.description:e.toString()); }
"></html>
-----------------------------

You can then embed it in another tiddler just by using <<tiddler
PasteBox>>. Note: because the above HTML/Javascript does not use a
specific ID to find the textarea contents, you can embed as many
copies as you like.

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"...
http://www.TiddlyTools.com/#Donations

Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions:
http://www.TiddlyTools.com/#Contact

TonyM

unread,
Aug 1, 2012, 8:49:02 PM8/1/12
to tiddly...@googlegroups.com
Eric,

Thanks a lot - This seems to be exactly what I want and need. On completion I will again post a suitable use case.

I have got it working - mostly, however the copy seems to ignore the new line character(s) in the source text area and the resultant pastes (after copy) are collapsed into single lines.

I imagine this could have been important in the original SaveToClipboard

How do I introduce the line feeds please ?

Thanks in Advance Tony

PS - I will send a tip in the near future sourced from $AUD
Reply all
Reply to author
Forward
0 new messages