Adobe 65007312 - Photoshop Lightroom Programmer's Manual page 104

Mac
Hide thumbs Also See for 65007312 - Photoshop Lightroom:
Table of Contents

Advertisement

C
5: Creating a User Interface for Your Plug-in
HAPTER
}
}
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
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 {
},
f:static_text {
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
}
}
LrBinding.kUnsupportedDirection
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
},
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
Binding UI values to data values 104
to indicate that one or the other

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Photoshop lightroom sdk 3.0

Table of Contents