Adobe 65007312 Programming Guide - Page 103
Complex bindings, Transforming values
UPC - 883919154398
View all Adobe 65007312 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 103 highlights
CHAPTER 5: Creating a User Interface for Your Plug-in Binding UI values to data values 103 Complex bindings The LrBinding functions provide a particular, limited set of value transformations. To specify more complex bindings, the argument to LrView.bind() can be a table with these items: key bind_to_object -or- object transform A key name in the bound table. The value can be mapped to a value for the local property by the transform function. Optional. The name of an observable table which overrides the value of the bind_to_object view property. Optional. A function that maps the key or key values to the local property value. See "Transforming values" on page 103. This function is called immediately when the value changes in either the bound view property or the bound table key. Here is an example of binding to keys in two different tables in a single view object: ... visible = LrView.bind("myBooleanSetting"), -- simple binding between two -- Booleans in the default table enabled = LrView.bind( { key = "mySetting", -- a single key bind_to_object = mySettingsTable, -- a non-default bound table transform = function( value, fromTable ) -- a mapping function ... end } ) ... Transforming values The transformation function that you specify for a binding maps the value of a key in the bound table to a value in the bound property. If the LrBinding functions do not provide mapping that you need, define your own transformation function. It is passed these parameters: value: The new value of the key or property that changed. fromTable (Boolean): True if the change that triggered this notification was in the bound table, false if the change was in the bound view property. Your function should return the new value for the destination property or key. This simple example creates a slider with a range of 0-110, then reports when the value goes over 100, by using a transformation function. The slider value and the visible property of a text box are bound to the same key. For the text box, the transform function returns true (making visible true) only when the value is over 100. sectionsForTopOfDialog = function(viewFactory, propertyTable) return { { title = "Section Title", viewFactory:slider { min = 0,