Skip to main content
Known Participant
October 8, 2024
Question

SDK Paste Previous?

  • October 8, 2024
  • 1 reply
  • 337 views

I was looking through the SDK documentation and cannot find a way to Paste Previous via the SDK. Am I missing something?

This topic has been closed for replies.

1 reply

johnrellis
Genius
October 9, 2024

Unfortunately, the SDK doesn't provide direct support for Paste Settings From Previous. You could implement it with a modest amount of effort by having a background task that polls once a second (say) for the currently selected photo (with catalog:getTargetPhoto ()) and remembers it as the user moves to another photo. Then your plugin can use photo:getDevelopSettings() and photo:applyDevelopSettings() to implement Paste Settings From Previous. 

 

My Any Source plugin uses such polling to implement a better "previous" command, and it has negligible CPU cost and never interferes with interactive use.

cwurzbachAuthor
Known Participant
October 10, 2024

@johnrellis thanks for the information! I'm surprised that this isn't built into the SDK.

 

With your solution, if a user waits more than the time allotted for the polling to paste, then the settings pasted will be from the current photo. How do you get around this?

johnrellis
Genius
October 10, 2024

I was proposing a continuously running background task like this:

local previousPhoto, currentPhoto

LrTasks.startAsyncTask (function ()
    while true do 
        local photo = catalog:getTargetPhoto ()
        if photo ~= currentPhoto then 
            previousPhoto, currentPhoto = currentPhoto, photo
            end 
        LrTasks.sleep (1)
        end
    end)

 

Then the paste-from-previous command would copy the settings from "previousPhoto" (if it is non-nil).