Skip to main content
Participant
December 30, 2012
Answered

Problem binding table to popup_menu

  • December 30, 2012
  • 1 reply
  • 1031 views

Hi,

I'm at first attempt to code a plugin for LR. I've just done most of the job I need but now I'm stuck with a tricky problem I can't solve my self

In a LrDialogs I would like to show a popup menu (aka combobox) with a list of all collection and collectionset of the catalog.

To retrive the collection list I call recursively getChildCollections and getChildCollectionSets and put results into a table. The problem is that I call them from within a LrTask, meantime the main UI thread complete and thus nothing appear in the dropdown. It seem the combo was built while the table that bind to items property was empty and when it was populated the GUI wasn't get notified.

Surely I miss something...can you point into the right direction?

Here the code I use (just a sample)

local LrView = import 'LrView'

local LrTasks = import "LrTasks"

local LrBinding = import 'LrBinding'

local LrDialogs = import 'LrDialogs'

local LrApplication = import 'LrApplication'

local LrFunctionContext = import 'LrFunctionContext'

local LrStringUtils = import 'LrStringUtils'

LrFunctionContext.callWithContext ("CollectionList", function (context)

          LrDialogs.attachErrorDialogToFunctionContext (context)

          local collectionsList = {}

          LrTasks.startAsyncTask(function ()

                    for key, child in pairs(catalog:getChildCollectionSets()) do

                              local name = LrStringUtils.lower(child:getName())

                              collectionsList[key] = { title = name, value = child.localIdentifier }

                    end

          end)

          local f = LrView.osFactory()

          LrDialogs.presentModalDialog {

                    title = "EasyWorkflow",

                    contents = f:row {

                              f:row {

                                        f:static_text {

                                                  title = "Collections",

                                        },

                                        f:popup_menu {

                                                  items = collectionsList

                                        },

                              }

                    }

          }

end)

This topic has been closed for replies.
Correct answer johnrellis

Put the entire code -- gathering the collections, opening the dialog -- in a single task. 

1 reply

johnrellis
johnrellisCorrect answer
Legend
December 30, 2012

Put the entire code -- gathering the collections, opening the dialog -- in a single task. 

Participant
December 30, 2012

So simple...I feel like a dumb :|

Thank a lot and many wishes for the new year!

Alex