Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

SDK / Is there any API to "copy to clipboard" ?

Advocate ,
Oct 12, 2024 Oct 12, 2024

Question for all the SDK gurus.

Is there any API to "copy to clipboard"?

On Mac one can copy any "static tex" in the UI and paste it but that IS NOT available to Windows.

For my plug-ins I have thought about allowing to double click on a static text to "copy to clipboard" .

I wish we had PDF with all the existing API and so on...like that I could search them.

 

.

TOPICS
SDK
420
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Oct 12, 2024 Oct 12, 2024

A plugin can run a utility program to copy text to the Mac or Windows clipboard:

https://community.adobe.com/t5/lightroom-classic-discussions/copy-to-clipboard/m-p/8859782

 

To allow the user to copy displayed text, a couple of my plugins use edit_fields() (which do allow copying). To make them read-only so the user won't accidentally change the displayed text, I use LrView.bind() and a transform function that discards the user's input. 

 

Here's a function that makes a scrollable-text control using

...
Translate
LEGEND ,
Oct 12, 2024 Oct 12, 2024

A plugin can run a utility program to copy text to the Mac or Windows clipboard:

https://community.adobe.com/t5/lightroom-classic-discussions/copy-to-clipboard/m-p/8859782

 

To allow the user to copy displayed text, a couple of my plugins use edit_fields() (which do allow copying). To make them read-only so the user won't accidentally change the displayed text, I use LrView.bind() and a transform function that discards the user's input. 

 

Here's a function that makes a scrollable-text control using that approach:

local function scrolledText (args)
     return f:scrolled_view {width = args.width, height = args.height, 
        horizontal_scroller = false, 
        f:edit_field {immediate = true, 
            height_in_lines = args.height_in_lines, 
            width = args.width - 12, 
            value = not args.readOnly and bind (args.key) or  
                LrView.bind {key = args.key, bind_to_object = prop,
                    transform = function (value, fromTable)
                        if fromTable then return value end
                        local orig = prop [args.key]
                        prop [args.key] = ""
                        prop [args.key] = orig
                        return orig end}}}

The magic is in the transform() function at the end. 

 

And he's an example of invoking it:

scrolledText {key = "result", readOnly = true, width = 450, height = 100, 
    height_in_lines = 80}

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Oct 12, 2024 Oct 12, 2024

Thanks @johnrellis for the quick reply.

 

I think that LrTasks.execute() to copy to clipboard will do.

But your code is mighty interesting 😍

 

In my Plug-ins I display list of static texts (not edit fields) and by double clicking each the user (me for now) could copy them to clipboard.

Double click is more explicit than single click and avoids mistakes for instace when moving around the UI.

Had to "invent" double click myself though.

 

Static text alredy offres mouse_down so it was a simpler shortcut I used.

It didn't cross my mind to use "Edit Fields" and much less use a transform function...too advanced for me 😅

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Oct 12, 2024 Oct 12, 2024
LATEST

To give a it of context the idea was to pass certain calculated values to the Print Module...but unfortunately the SDK doens't allow it.

 

So copying to clicpboard is the only way (after one must paste 😵💫😵💫 in the good fields)

 

.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines