5 Replies Latest reply on Jul 29, 2017 7:07 PM by johnrellis

    popup_menu items

    komana909

      Hi All,

       

      I want to use an array as my popup_menu items. The Index of my array is coming from a different popup_menu item.

      In other words, items of my second popup_menu should be changed according to selected item of the first popup_menu.

       

      I need to use bind 'my_value' as my array index like in below.

       

       

      f:popup_menu {

                width = 250, -- the shared binding

                height = 180, -- the shared binding

                items = MyArray[bind 'my_value'],

              },

       

      How can I achieve to do this?

       

      Thanks in advance

       

       

        • 1. Re: popup_menu items
          johnrellis Most Valuable Participant

          Set "items" to a binding with a transform function that returns MyArray [prop.my_value], where "prop" is the property table for the dialog.  See page 106 of the Lightroom SDK Guide for an example of using a transform function.

          • 2. Re: popup_menu items
            komana909 Level 1

            Thank you for the reply. I've done this.

            I have one more question. How can I call a function when the textbox or slider change? Now I call a function, only when "button ok" is clicked.

            • 3. Re: popup_menu items
              johnrellis Most Valuable Participant
              How can I call a function when the textbox or slider change?

              There are two ways of doing that. You can use a binding with a transform() function that calls your desired function, or you can add an observer to the value property of the edit_field or slider (see page 184 of the SDK Guide).

              1 person found this helpful
              • 4. Re: popup_menu items
                komana909 Level 1

                Many thanks for your answer.

                As far as I see, we can capture an editbox value only when lost the focus. There is no option for, like in classical development languages, capture the change or

                There is no option for, like in classical development languages, capture the change or keypress? Correct?

                • 5. Re: popup_menu items
                  johnrellis Most Valuable Participant

                  Use the "immediate" property for viewFactory:edit_field() -- then observer and transform functions will be called each time the user types a key.  See the API Reference for LrView for details.