0

Copy to Clibboard button

Can I create a button to select the contents of a field and copy them to Clipboard? (In FM Pro that was v straightforward)

43 replies

null
    • Sean
    • 2 yrs ago
    • Accepted
    • Reported - view

    Max, I don't know which version you are using, but this one worked for me...

     

    html("<button onclick='copyToClipboard(""" + 'Formula Field' + """)'>Copy to clipboard</button>
    <script>
    function copyToClipboard(str) {
    var el = document.createElement('textarea');
    el.value = str;
    el.setAttribute('readonly', '');
    el.style.position = 'absolute';
    el.style.left = '-9999px';
    document.body.appendChild(el);
    el.select();
    document.execCommand('copy');
    document.body.removeChild(el);
    }
    </script>")

     

    Hans, Not that I'm aware of, but you can use "style" to modify the appearance of the button. Search on style for the HTML button tag.

    • Birger_H
    • 4 yrs ago
    • Reported - view

    Copy to Clipboard is not yet available :-(

    Birger

    • Personal
    • Art
    • 4 yrs ago
    • Reported - view

    Sad to see it's not available yet. I would use this.

    • CentralGamer
    • 3 yrs ago
    • Reported - view

    Me too!

    • james_deraps
    • 3 yrs ago
    • Reported - view

    Must be add!!!

    • Karen_Estrada
    • 3 yrs ago
    • Reported - view

    ++ :-)  as well! KE

    • blickfang Internet- & Werbeagentur GmbH
    • Timo_L
    • 3 yrs ago
    • Reported - view

    need this, too!

    • majlo
    • 3 yrs ago
    • Reported - view

    :( need this, too

    • lanematthewc
    • 3 yrs ago
    • Reported - view

    I would also find this very useful. Thanks for all your work! =)

    • Retraité
    • Eric_Plet
    • 3 yrs ago
    • Reported - view

    need this too.

    • Kaan_Dikmen
    • 2 yrs ago
    • Reported - view

    This would be very useful to send data to Shortcuts workflows. 1+ !!!

    • Halio
    • Halio
    • 2 yrs ago
    • Reported - view

    Any update on this?

    Just to clarify, there is no way to program a button to copy the content from a field to the clipboard?

    • Sean
    • 2 yrs ago
    • Reported - view

    Hello, I found this solution online and adapted it to work in Ninox. The code goes in Formula field and it copies the current record information to the clipboard...

     

    html("<button onclick='copyToClipboard(""" + concat(this) + """)'>Copy to clipboard</button>
    <script>
    function copyToClipboard(str) {
    var el = document.createElement('textarea');
    el.value = str;
    el.setAttribute('readonly', '');
    el.style.position = 'absolute';
    el.style.left = '-9999px';
    document.body.appendChild(el);
    el.select();
    document.execCommand('copy');
    document.body.removeChild(el);
    }
    </script>")

    • Hans
    • 2 yrs ago
    • Reported - view

    Thanks Sean, that works! 

    Is there any way to make it focus on the contents of just one field in the record?

    • Sean
    • 2 yrs ago
    • Reported - view

    Not that I'm aware of. It is a long awaited feature request.

    • Hans
    • 2 yrs ago
    • Reported - view

    I see that. :) Looking forward to the development. 

    • Bastian Rohde Immobilien
    • Bastian_Rohde
    • 2 yrs ago
    • Reported - view

    sure that works - you just need to replace this piece here in the first line:

     concat(this) 

    I have replaced this with one column and it works.

    • Bastian Rohde Immobilien
    • Bastian_Rohde
    • 2 yrs ago
    • Reported - view

    thanks Sean for sharing - this was really helpful!

    • Hans
    • 2 yrs ago
    • Reported - view

    Bingo! That is the perfect solution.

    Just in case anyone is unclear about how to make this work...

    Use the "Fx Formula" option to add a formula field to your record. (I.e. not a button field - tried that, didn't work)

    Add the following code where the Formula code goes:

    html("<button onclick='copyToClipboard(""" + concat('Project Name') + """)'>Copy to clipboard</button>
    <script>
    function copyToClipboard(str) {
    var el = document.createElement('textarea');
    el.value = str;
    el.setAttribute('readonly', '');
    el.style.position = 'absolute';
    el.style.left = '-9999px';
    document.body.appendChild(el);
    el.select();
    document.execCommand('copy');
    document.body.removeChild(el);
    }
    </script>")

     

    Where I have:

    'Project Name'

    in concat('Project Name')

    is where you will want to put the name of the field you want to copy. If you want to copy the whole record, simply add the word

    this

    as in contcat(this)

    ...and you are done, and Ninox has one less development item on their list.

    • Sean
    • 2 yrs ago
    • Reported - view

    Sorry, I misunderstood your question. I thought you wanted set the focus of a Ninox field. D'oh! 😬

    • hughbs
    • 2 yrs ago
    • Reported - view

    Thank you Sean and Hans, the perfect solution! And one can change the name on the button to the name of the field being copied.

    • Hans
    • 2 yrs ago
    • Reported - view

    For the record, Sean and Bastian did the heavy lifting. I'm just really good at copy paste. :)

    • Retraité
    • Eric_Plet
    • 2 yrs ago
    • Reported - view

    a specific character contained in the field to copy prevents this script from working: '

    • Retraité
    • Eric_Plet
    • 2 yrs ago
    • Reported - view

    sample text:

    youtube-dl -f 251 --no-cache-dir -o '/Library/WebServer/Documents/Médiathèque/ Commodores/The Commodores Anthology/Easy (Extended Version)/Easy (Extended Version) - Album Studio - Opus 160k.%(ext)s' https://youtu.be/-_z35XZWiP4

    • Sean
    • 2 yrs ago
    • Reported - view

    The only sort-of-solution I found was this...

     

    html("<button onclick='copyToClipboard(""" + replace(FieldToCopy, "'", "") + """)'>Copy to clipboard</button>
    <script>
    function copyToClipboard(str) {
    var el = document.createElement('textarea');
    el.value = str;
    el.setAttribute('readonly', '');
    el.style.position = 'absolute';
    el.style.left = '-9999px';
    document.body.appendChild(el);
    el.select();
    document.execCommand('copy');
    document.body.removeChild(el);
    }
    </script>")

     

    If you insert the string directly it works, but it's not what you're looking for. I'm not sure how to get around it.

     

    html("<button onclick='copyToClipboard(""youtube-dl -f 251 --no-cache-dir -o '/Library/WebServer/Documents/Médiathèque/ Commodores/The Commodores Anthology/Easy (Extended Version)/Easy (Extended Version) - Album Studio - Opus 160k.%(ext)s' https://youtu.be/-_z35XZWiP4"")'>Copy to clipboard</button>
    <script>
    function copyToClipboard(str) {
    var el = document.createElement('textarea');
    el.value = str;
    el.setAttribute('readonly', '');
    el.style.position = 'absolute';
    el.style.left = '-9999px';
    document.body.appendChild(el);
    el.select();
    document.execCommand('copy');
    document.body.removeChild(el);
    }
    </script>")

Content aside

  • Status Answered
  • 1 yr agoLast active
  • 43Replies
  • 6598Views
  • 5 Following