Adobe 65007312 Programming Guide - Page 96
Simple bindings, For some other common types of binding, you can use an
UPC - 883919154398
View all Adobe 65007312 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 96 highlights
CHAPTER 5: Creating a User Interface for Your Plug-in Binding UI values to data values 96 You can then use the shortcut to specify dynamic property values: ... viewFactory:static_text { title = bind 'mySetting', ... The required argument of LrView.bind() is the key name; by default, this is in the table that is already bound to the UI element; that is, the value of bind_to_object in the same UI element. This is inherited in the view hierarchy, but can be overridden at any level. You can override the bound table for a specific binding by passing the LrView.bind() function a table containing both the key and the table it comes from: visible = LrView.bind { key = "mySetting", bind_to_object = "myTable" } This allows you to bind different properties in one view object to keys in different tables. The bound table is typically the export-settings table, since your UI is typically a way for your user to see and set these values. The SDK makes this default case easy for sections that you define for the Export dialog. In views created with sectionsForTopOfDialog and sectionsForBottomOfDialog, the value of bind_to_object for the entire view hierarchy is set automatically to the export-settings table passed along with the view factory. See "Adding custom sections to the Plug-in Manager" on page 32. Simple bindings The simplest binding is between a property in the LrView object and a settings key of the same datatype, and simply keeps the two synchronized. For example: visible = LrView.bind( "LR_export_useSubfolder" ) In this case, both the local property (visible) and the bound table item (a Lightroom-defined export setting) have Boolean values. Setting the use-subfolder preference to true (in the Export dialog, for instance) makes the control visible. For some other common types of binding, you can use an LrBinding function as the value assignment; for example: visible = LrBinding.negativeOfKey( "LR_export_useSubfolder" ) This binds the property to the opposite of the table value; that is, setting the use-subfolder preference to true hides the control. The binding works in both directions; that is, hiding the control would also set LR_export_useSubfolder to true. This function can be used to negate numeric as well as Boolean values; for example, a value of 2 would become -2. Although negativeOfKey() works both ways, and with numeric values, the other LrBinding functions can be used only with Boolean values, and work only in one direction; a change in the bound table sets the bound property value, but not the reverse. The LrBinding functions allow you to: X Set a Boolean property to the opposite of a Boolean key value, or a numeric property to the negation of a numeric key value (LrBinding.negativeOfKey). X Set a Boolean property when a key value is or is not present (LrBinding.keyIsNil, keyIsNotNil). X Set a Boolean property when a key value is or is not equal to a specific value (LrBinding.keyEquals, keyIsNot).