Skip to main content
Known Participant
Oct 8, 2024 9:47 PM UTC
Question

SDK Paste Previous?

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

This topic is closed to new replies. Start a new post to keep the conversation going.

4 replies

johnrellis
Legend
Oct 9, 2024 3:04 AM UTC

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.

Translate
cwurzbachAuthor
Known Participant
Oct 10, 2024 12:50 AM UTC

@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?

Translate
johnrellis
Legend
Oct 10, 2024 3:48 AM UTC

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).

Translate