3 Replies Latest reply: Jun 25, 2009 7:50 AM by jsteinme RSS

    Binding problem in LrPluginInfoProvider.sectionsForBottomOfDialog




      I have a binding problem in my LrPluginInfoProvider.sectionsForBottomOfDialog function, and i cannot make it work; i've read all the docs, view all the samples, but i just can´t see where the problem is ...


      I have this code in my Info.lua


      return {


           LrPluginInfoProvider = 'PluginInfoProvider.lua',




      PluginInfoProvider.lua has this code:


      require 'PluginManager'


      return {
          sectionsForBottomOfDialog = PluginManager.sectionsForBottomOfDialog,


      And this is PluginManager.lua:


      local LrView = import 'LrView'
      local LrDialogs = import 'LrDialogs'
      local LrLogger = import 'LrLogger'


      local myLogger = LrLogger('logger')


      PluginManager = {}


      function PluginManager.sectionsForBottomOfDialog(viewFactory, propertyTable)


          propertyTable.text = ""
          propertyTable.buttonEnabled = false


          return {
                  title = "Test",
                  viewFactory:row {
                      spacing = viewFactory:control_spacing(),
                      viewFactory:static_text {
                          title = LOC "Text",
                      viewFactory:edit_field {
                          value = LrView.bind "text",
                          validate = function( view, value )
                              if #value > 0 then -- check length of entered text
                                  propertyTable.buttonEnabled = true
                                  propertyTable.buttonEnabled = false
                              return true, value
                      viewFactory:push_button {
                          enabled = LrView.bind 'buttonEnabled',
                          action = function(button)
                                  myLogger:trace("Test value")


      As far as i know, the button should enable only when there is some info in the text field and log file should show the text field value, but it only displays "Test value" and the button is always enabled.


      Any idea? i'm really with this ... (i don't know if matters, but i'm testing this in a WinXP machine with LR 2.3)


      Thanks in advance,

        • 1. Re: Binding problem in LrPluginInfoProvider.sectionsForBottomOfDialog
          Mark J M Wilson Community Member

          It looks like you need to tell the controls which property table to bind to.


          In this code, try adding "bind_to_object = propertyTable," to the row.


          To make the button enable as soon as there is more than 0 chars in the textbox, add "immediate = true," to the edit_field.  This will run the validate function as the user types.

          • 2. Re: Binding problem in LrPluginInfoProvider.sectionsForBottomOfDialog
            K3k0 Community Member

            Thanks Mark,


            I knew about inmediate property, just forgot tu un-comment it


            I've added "bind_to_object = propertyTable" as you say, but it didn't work; i've renamed the parameter propertyTable to propTable and now it does ... and i've no idea why


            Anyway, it's working ok, so thanks for your answer.

            • 3. Re: Binding problem in LrPluginInfoProvider.sectionsForBottomOfDialog
              jsteinme Community Member

              As you have figured out, the value of the edit_field will not change until it is validated and it will only be validated with every keystroke when "immediate = true".


              Another way to accomplish this would be to bind the enabled state of the button to the value of the edit field. Such as:


              enabled = LrView.bind {

                   key = "text",

                   transform = function( value, fromTable )

                        if fromTable then

                             if value ~= nil and value ~= "" then

                                  return true


                             return false





              (This was not tested but should be close)


              The advantage of this is that the button will be enabled and disabled without the validation of the edit_field needing to be called. So if the value of the text field is changed programatically the button will be updated.