0 Replies Latest reply on Jan 19, 2017 12:32 PM by johnrellis

    Cascading menus

    johnrellis Most Valuable Participant

      I just accidentally stumbled on how to make cascading popup menus -- you nest the items passed to popup_menu() in the (now) obvious way:

       

      local LrBinding = import 'LrBinding'
      local LrDialogs = import 'LrDialogs'
      local LrFunctionContext = import 'LrFunctionContext'
      local LrView = import 'LrView'
      
      local bind = LrView.bind
      local f = LrView.osFactory()
      
      local items = {
          {title = "Item 0", value = "0"},
          {title = "Item 1", 
              {title = "Item 1.a", value = "1.a"},
              {title = "Item 1.b", value = "1.b"}},
          {title = "Item 2", 
              {title = "Item 2.a", value = "2.a"},
              {title = "Item 2.b", value = "2.b"}}}
      
      LrFunctionContext.callWithContext ("", function (context)
          local prop = LrBinding.makePropertyTable (context)
          LrDialogs.presentModalDialog {title = "Nested Menu", 
              contents = f:popup_menu {items = items, value = bind ("v"),
                  bind_to_object = prop}}
      
          LrDialogs.message ("Selected item", prop.v)
          end)
      

       

      Here's what it looks like:

      This is undocumented, so who knows whether it will remain "supported" in future versions (as much as anything in the SDK is "supported" these days).