I am no Lua coder but am muddling my way through.
Here's my problem:
I have a dialog set up which allows a user to select from a dropdown any of the currently selected images. The remainder of the dialog will fill with the chosen image's metadata. The user can make changes. When done they press OK and the changes are written back to the catalog.
I must be missing something somewhere because whatever image is up when the user presses OK is the source for the metadata. So, all images selected get that image's metadata instead of what was in the fields for each image.
Here's the code used to write back the data.
activeCatalog:withWriteAccessDo( "Plugin Title", function()
local photosToUpdate = activeCatalog.targetPhotos
for i, photo in ipairs(photosToUpdate) do
photo:setRawMetadata('title',propertyTable.imageTitle)
photo:setRawMetadata('caption', propertyTable.imageDescription)
photo:setPropertyForPlugin(_PLUGIN,'relProperty', propertyTable.propertyReleaseStatus)
photo:setPropertyForPlugin(_PLUGIN,'relPropertyFile', propertyTable.propertyReleaseFile)
end
end )
Thanks Mark!
No, I have the bind_to_object in place. Since the write back code looks OK I am thinking that perhaps having the write back in the same function as the dialog box might be the problem. I could stick it in a separate function to be called after the dialog is closed but I am not sure how to pass the propertyTable on to the next function. As I said I'm no Lua coder. ![]()
Do you think that would work? How do I pass the propertyTable from one function to the other?
Gene McCullagh wrote:
No, I have the bind_to_object in place. Since the write back code looks OK I am thinking that perhaps having the write back in the same function as the dialog box might be the problem. I could stick it in a separate function to be called after the dialog is closed but I am not sure how to pass the propertyTable on to the next function. As I said I'm no Lua coder.
Do you think that would work? How do I pass the propertyTable from one function to the other?
A property table is just another variable. You can return it and pass it into a function. Or declare it in a higher/wider scope and treat it as a global variable. This plugin of mine is open source and uses property tables to exchange data between a dialog and other functions. Don't know whether it will resolve your problem but you might as well give it a shot.
Matt
North America
Europe, Middle East and Africa
Asia Pacific