6 Replies Latest reply on Jul 12, 2010 6:31 AM by DawMatt

    How to Create a Dynamic User Interface


      I am trying to make a dynamic user interface by getting data from a web service that creates X amount of check boxes.  How do I do this?  I read the documentation, but there is no function that allows you to create a UI component and add it as a child of another component.  I know it can be done since other plugins have similar functionality.

        • 1. Re: How to Create a Dynamic User Interface
          johnrellis Most Valuable Participant

          I haven't found any documented method for adding controls to a dialog that's being displayed.  But there are techniques you could use to solve your problem:


          1. After you get the data and know how many controls you need, close the first dialog and open a second one with the right number of controls.


          2. Create the maximum number of controls, setting .visible = false to hide them.  Unhide as many as necessary after you've received the data.

          1 person found this helpful
          • 2. Re: How to Create a Dynamic User Interface
            DawMatt Level 3



            I was asking exactly the same question of fellow plugin developers yesterday and got basically the same answer.


            An option 3) to consider to fake the desired UI is to create a grid of controls and simulate a scrolling area using buttons/sliders, so it looks like data is scrolling out of view but in reality you are just shifting all of the data displayed via bound values.  Painful, but I believe this is what Jeffrey had to do in some of his plugins.



            1 person found this helpful
            • 3. Re: How to Create a Dynamic User Interface
              Allen Gambrell Level 1

              Yes this is a big drawback of the Lightroom SDK. You can display dynamic data on a static interface, but you cannot create a dynamic user interface.


              The best ways to get arond this is use the scrolling idea like before and hiding controls in views and turning on and off the visibility.

              • 4. Re: How to Create a Dynamic User Interface
                areohbee Level 6

                +1 vote - better UI controls, especially for creating dynamic and non-modal user interfaces...

                • 5. Re: How to Create a Dynamic User Interface
                  sandwicense Level 1

                  I decided to get the data within the exportServiceprovider.startDialog() function and since I need to connect to a server I am using LrHttp.get() function, i need to use the LrTasks.startAsyncTask() function.  So, after getting and processing the results I return the user interface (e.g. f:row {}) and insert it into a table that is then displayed in the exportServiceProvider.sectionsForBottomOfDialog() section.  The problem is, it seems, by the time the asynchronous task finishes, it's too late for it to have any effect, since the sectionsForBottomOfDialog seems to be finished already.  I also get the following error: ?:0 attempt to call method 'hierarchyCreated' (a nil value).  Can this not be done, and is just another limitation of the SDK?

                  • 6. Re: How to Create a Dynamic User Interface
                    DawMatt Level 3



                    I saw the hierarchyCreated error just recently and it went away when I restructured part of my code.


                    If you are passing f:rows from the startDialog() function to the sectionsForBottomOfDialog() function that could be the problem. You might be better off passing the raw table and assembling the f:rows in the function that displays the dialog.