Bindings For Selection Controls - Adobe 65007312 - Photoshop Lightroom Programmer's Manual

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

Advertisement

C
5: Creating a User Interface for Your Plug-in
HAPTER
For example:
LrFunctionContext.callWithContext("showCustomDialog", function( context )
local myPropTable = LrBinding.makePropertyTable( context )
mypropTable:addObserver( 'mySetting', function( properties, key, newValue )
-- do something when this value changes
end )
-- add code to create dialog contents
end)
The handler function you specify for your observer takes as arguments the observed table (so you can
access other data values), the key whose value change triggered the notification (in case you are using the
same handler function for multiple keys), and the new value of that key.
You can define a function to handle more than one key notification, using the
which key changed. If you do, you must pass the function to a separate
For examples of how and why to add an observer to a table, see
page
101, and

Bindings for selection controls

Controls that have a selection state include checkboxes, radio buttons, pop-up menus, and (to some
extent) combo boxes. You can use bindings to keep track of the selection state, and to create
dependencies between what is selected in one of these controls and what is shown elsewhere in the UI, or
what actions are taken.
Binding checkbox selections
The
value
In both, if the user checks the button, the
In the checkbox, if the user unchecks the button, the
value
E
XAMPLE
local LrBinding = import "LrBinding"
local LrDialogs = import "LrDialogs"
local LrFunctionContext = import "LrFunctionContext"
local LrView = import "LrView"
local bind = LrView.bind -- shortcut for bind() method
LrFunctionContext.callWithContext( 'bindingButtonsExample', function( context )
local f = LrView.osFactory() -- obtain view factory
local properties = LrBinding.makePropertyTable( context ) -- make prop table
-- create some keys with initial values
properties.checkbox_state = 'checked' -- for checkbox
properties.my_value = 'value_1' -- for radio buttons and pop-up menu
local contents = f:column { -- create view hierarchy
fill_horizontal = 1,
spacing = f:control_spacing(),
bind_to_object = properties, -- default bound table is the one we made
f:group_box {
Chapter 9, "Getting Started: A Tutorial
property of a radio button or checkbox controls and reflects the current selection state:
.
1: This example shows how bindings work in checkboxes:
title = "Checkboxes", -- (only one here)
fill_horizontal = 1,
spacing = f:control_spacing(),
"Binding combo box selections" on
Example.
becomes the new control
checked_value
unchecked_value
Binding UI values to data values 98
argument to distinguish
key
call for each key.
addObserver()
value
becomes the new control
.

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Photoshop lightroom sdk 3.0

Table of Contents