Adobe 65007312 Programming Guide - Page 104
direction is not supported by your transformation., to indicate that one or the other
UPC - 883919154398
View all Adobe 65007312 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 104 highlights
CHAPTER 5: Creating a User Interface for Your Plug-in Binding UI values to data values 104 max = 110, value = LrView.bind "slider_value", title = "slider title", }, viewFactory:static_text { title = "You're over a hundred", visible = LrView.bind { key = "slider_value", transform = function(value, fromTable) return value > 100 end } } } } end Transformations can work in both directions; changes in the bound property affect the bound table key, and changes in the table key affect the property. If you write a custom function for a one-way transformation, return the value LrBinding.kUnsupportedDirection to indicate that one or the other direction is not supported by your transformation. Here is an example of a one-way transformation. This example shows a transformation that makes a text display visible only when text is entered in an edit field. The transform function checks for a value of nil or the empty string in the key to which both controls are bound. This example pops up a dialog, so it needs to create an observable table to hold the data. local LrBinding = import "LrBinding" local LrDialogs = import "LrDialogs" local LrFunctionContext = import "LrFunctionContext" local LrView = import "LrView" LrFunctionContext.callWithContext( 'bindingExample', function( context ) local f = LrView.osFactory() -- obtain the view factory local properties = LrBinding.makePropertyTable( context ) -- make a settings table -- the new table is initially empty local contents = f:column {-- create view hierarchy for dialog spacing = f:control_spacing(), bind_to_object = properties, -- default bound table is the one we made f:row { fill_horizonal = 1, spacing = f:label_spacing(), f:static_text { title = "Type anything:", alignment = 'right', }, f:edit_field { fill_horizonal = 1, width_in_chars = 20, immediate = true, value = LrView.bind( 'text' ), -- creates a key 'text' -- the initial value of the new key is nil -- setting its value (by entering text in the control) -- puts it into the table }, }, f:static_text { place_horizontal = 0.5, title = "This is only visible when there is text in the edit field", visible = LrView.bind { key = 'text', -- bind to the same key