3 Replies Latest reply on Nov 24, 2011 12:22 AM by areohbee

    Binding to multiple keys

    tvansteelandt

      Hi all

       

      I'm struggling with finding the solution of binding the value of a labeled_text_input to multiple keys in multiple tables.

      Does anyone here have experience with that?

      I've tried the code in the LR sdk guide, under binding multiple keys.

      Doesn't work.

       

      Any help is greatly appreciated!

       

      Grtz

        • 1. Re: Binding to multiple keys
          areohbee Level 5

          This works:

           

          local props = LrBinding.makePropertyTable( context )

           

          local args = {}

          args.title = "ttl"

          local main = {}

          main[#main+1] = vf:row {

              vf:checkbox{

                  bind_to_object = props,

                  value = bind 'cb',

                  enabled = LrView.bind {

                      keys = { { key = 'k1', bind_to_object = props }, { key = '_global_k2', bind_to_object = prefs } },

                      operation = function( binder, value, toView )

                          local b = props.k1 or prefs._global_k2

                          return b

                      end,

                  },

              }

          }

          props.cb = true

          props.k1 = true

          prefs._global_k2 =  false

          args.contents = vf:column( main )

          local r = LrDialogs.presentModalDialog( args )

          -- Note: 'prefs' is LrPrefs.prefsForPlugin()

          • 2. Re: Binding to multiple keys
            tvansteelandt Level 1

            hi Rob,

            thanks for your reply.

            I'm not familiar with propertytables.

            What I'm actually writing is a webengine, not a global plugin.

            I don't know if that changes the idea or what.

             

            Here's my code:

            f:labeled_text_input {
                      title = "Password",
                      value = bind {
                           keys = {
                           {
                                key = "metadata.password"
                           },
                           {
                                key = "client_password",
                                bindToObject = output_props
                           }
                      },
                      operation = function() end
                 },
            },
            

             

            The first key is bound to the default object, being the controller, so that it binds to my model metadata.

            The second key I want to bind to a table defined in my views.

            I'm not really sure something has to happen within the operation function.

             

            Or is it possible that it just doesn't work with a f:labeled_text_input?

             

            Thanks

            • 3. Re: Binding to multiple keys
              areohbee Level 5

              Sorry - I'm not very familiar with the webengines - maybe somebody more familiar will grace by...