2 Replies Latest reply on Dec 29, 2012 6:25 PM by Alessandro Di Noia

    Problem binding table to popup_menu

    Alessandro Di Noia


      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 }
                local f = LrView.osFactory()
                LrDialogs.presentModalDialog {
                          title = "EasyWorkflow", 
                          contents = f:row {
                                    f:row {
                                              f:static_text {
                                                        title = "Collections",
                                              f:popup_menu {
                                                        items = collectionsList