Namespace LrBinding

This namespace allows you to create observable properties tables, and to define common relationships between UI elements and data property values.

Access these functions directly from the imported namespace.

The makePropertyTable() function creates an observable table, in which you can store program data that you can associate with dynamic values in your UI.

Use the transformation functions as the value argument to LrView.bind(). These functions perform very common transformations between the source value of a binding (that is, the value whose change triggered a notification, typically an export-settings value in a property table) and the destination value (the other end of the binding, typically a view property such as "visible" or "enabled").

Bindings can work in both directions; that is, a change in the bound table affects the value of the view property, and changing the view property affects the table's key value. However, these functions (except as noted) create one-way bindings. They only change the bound view property when a bound table's key value changes, not the reverse.

For example, this creates a binding that hides the control when the value of "mySetting" becomes true:

 binding = { visible = LrBinding.negativeOfKey( "mySetting" ) }

Summary

LrBinding.andAllKeys( optObject, keys )
Creates a binding that determines if the values of all the source keys evaluate to true.
LrBinding.keyEquals( key, compareValue, optObject )
Creates a binding that determines if the source value is equal to a comparison value.
LrBinding.keyIsNil( key, optObject )
Creates a binding that determines if the source value is not present.
LrBinding.keyIsNot( key, compareValue, optObject )
Creates a binding that determines if the source value is not equal to a comparison value.
LrBinding.keyIsNotNil( key, optObject )
Creates a binding that determines if the source value is present.
LrBinding.makePropertyTable( functionContext )
Creates a table that automatically sends notifications whenever values in the table are changed.
LrBinding.negativeOfKey( key, optObject )
Creates a binding that negates the source value, if it is Boolean or numeric.
LrBinding.orAllKeys( optObject, keys )
Creates a binding that determines if the values of any of the source keys evaluate to true.
Your transformation function should return this value to indicate that the current direction is not supported by the transform.

Functions

LrBinding.andAllKeys( optObject, keys )
Creates a binding that determines if the values of all the source keys evaluate to true. The return value is placed in the bound view property, which must be Boolean.

First supported in version 1.3 of the Lightroom SDK.

Parameters

1. optObject
(table, optional) If specified, overrides the default bound table.
2. keys
(strings or tables) Additional arguments for the keys whose values are observed. An argument can be a simple string (a key name from the bound table), or a table that specifies a key from a different table, as a key-value pair:
  • key A key name.
  • bind_to_object or object The name of an observable table which overrides the current bound table.

Return value

(Boolean) True if all of the source values evaluate to true, false otherwise.
LrBinding.keyEquals( key, compareValue, optObject )
Creates a binding that determines if the source value is equal to a comparison value. The return value is placed in the bound view property, which must be Boolean.

First supported in version 1.3 of the Lightroom SDK.

Parameters

1. key
(string) The key to bind to.
2. compareValue
(any) The key in the bound table whose value is observed.
3. optObject
(table, optional) If specified, overrides the default bound table.

Return value

(Boolean) True if the source value is equal to the comparison value, false otherwise.
LrBinding.keyIsNil( key, optObject )
Creates a binding that determines if the source value is not present. The return value is placed in the bound view property, which must be Boolean.

First supported in version 1.3 of the Lightroom SDK.

Parameters

1. key
(string) The key in the bound table whose value is observed.
2. optObject
(table, optional) If specified, overrides the default bound table.

Return value

(Boolean) True if the source value is nil, false otherwise.
LrBinding.keyIsNot( key, compareValue, optObject )
Creates a binding that determines if the source value is not equal to a comparison value. The return value is placed in the bound view property, which must be Boolean.

First supported in version 1.3 of the Lightroom SDK.

Parameters

1. key
(string) The key in the bound table whose value is observed.
2. compareValue
(any) The value to compare against.
3. optObject
(table, optional) If specified, overrides the default bound table.

Return value

(Boolean) True if the source value is not equal to the comparison value, false otherwise.
LrBinding.keyIsNotNil( key, optObject )
Creates a binding that determines if the source value is present. The return value is placed in the bound view property, which must be Boolean.

First supported in version 1.3 of the Lightroom SDK.

Parameters

1. key
(string) The key in the bound table whose value is observed.
2. optObject
(table, optional) If specified, overrides the default bound table.

Return value

(Boolean) True if the source value is not nil, false otherwise.
LrBinding.makePropertyTable( functionContext )
Creates a table that automatically sends notifications whenever values in the table are changed. You can set this as the bound table for an LrView object, or pass it as the optObject to any of the LrBinding functions.

You can also call addObserver() on this table to register any object for notification when values in this table are changed.

You must call this function with a function context, so that Lightroom can remove notifications when the table is no longer needed.

First supported in version 1.3 of the Lightroom SDK.

Parameters

1. functionContext
(LrFunctionContext) The function-context object that manages the lifetime of this property table. All notifications are canceled automatically when the context exits

Return value

(LrObservableTable) The observable table.

See also

LrView, LrFunctionContext
LrBinding.negativeOfKey( key, optObject )
Creates a binding that negates the source value, if it is Boolean or numeric. For a value of any other type, the transformation returns nil. This is a two-way binding; changes in the view property also place the negated value in the bound table key.

First supported in version 1.3 of the Lightroom SDK.

Parameters

1. key
(string) The key in the bound table whose value is observed.
2. optObject
(table, optional) If specified, overrides the default bound table.

Return value

(Boolean or number)
  • True if the source value is false, false if it is true.
  • The negation of a numeric value.
  • Nil for a source value of any other type.
LrBinding.orAllKeys( optObject, keys )
Creates a binding that determines if the values of any of the source keys evaluate to true. The return value is placed in the bound view property, which must be Boolean.

First supported in version 1.3 of the Lightroom SDK.

Parameters

1. optObject
(table, optional) If specified, overrides the default bound table.
2. keys
(table) The keys whose values are observed. Entries can be simple key names from the bound table, or you can specify a key in another table, using a key-value pair, in which the value part can be a table with these items:
  • key A key name
  • bind_to_object or object Optional. The name of an observable table which overrides the current bound table.

Return value

(Boolean) True if any of the source values evaluate to true, false otherwise.

Properties

LrBinding.kUnsupportedDirection : (Read-Only)
Your transformation function should return this value to indicate that the current direction is not supported by the transform. Bindings can work in both directions; that is, a change in the bound table affects the value of the view property,and changing the view property affects the table's key value. When writing your own transformation functions, you can choose to support only one direction.

First supported in version 1.3 of the Lightroom SDK.