Adobe 65007312 Programming Guide - Page 94

Text view properties, Binding UI values to data values

Page 94 highlights

CHAPTER 5: Creating a User Interface for Your Plug-in Binding UI values to data values 94 Text view properties These properties apply to any control that displays text, including popup_menu, static_text, and push_button, as well as the editable text controls. Property Datatype width_in_chars number width_in_digits number height_in_lines number Description Calculates the minimum width using this as the number of m characters that should fit. Considered together with width_in_digits. Default is 15 for editable text fields. Calculates the minimum width using this as the number of 0 digits that should fit. Considered together with width_in_chars. Default is 0. Calculates the minimum height using this as the number of lines that should fit within the field. Default is 1. Binding UI values to data values Bindings allow you to make your UI dynamic by specifying a relationship between an LrView object's state and current values in an observable table (see "Creating observable property tables" on page 97). This can be the export-settings property table provided by the API, or a table that you create for local program data that you define. When you create a binding, the value or state of the UI element reflects the data value, and the data value reflects the UI element state. This is a two-way relationship; when the binding is established, the data value from the table is pushed to the view, and when the user changes the bound value in the view (by selecting a checkbox, for instance, or entering a value in a text field), the table is notified and the corresponding data key value or values change accordingly. Similarly, when your program changes a value in the table, the bound UI elements are updated to display the new value. To create bindings: 1. Specify a bound table at some level of the view hierarchy. Set the table as the value of the bind_to_object property (you can also use the name object for this property). The bound table of a parent container is inherited by its children, but can be overridden. Z When you create a dialog box, you must set the bound table explicitly. Z When you create a section for the Plug-in Manager or Export dialog using the sectionsForTopOfDialog or sectionsForBottomOfDialog functions, the settings table for your plug-in is passed to those functions as the propertyTable value. This table contains both export settings that you have defined for your plug-in (see "Remembering user choices" on page 57) and Lightroom-defined export settings (see "Lightroom built-in property keys" on page 59). The propertyTable is automatically set as the default bound table for all of the UI elements in the view hierarchy for that section. However, the bindable synopsis for the section is not part of the view hierarchy; if you want to make that value dynamic, you must specify the table explicitly. See "Adding custom sections to the Plug-in Manager" on page 32.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204

C
HAPTER
5: Creating a User Interface for Your Plug-in
Binding UI values to data values
94
Text view properties
These properties apply to any control that displays text, including
popup_menu
,
static_text
, and
push_button
, as well as the editable text controls.
Binding UI values to data values
Bindings
allow you to make your UI dynamic by specifying a relationship between an
LrView
object’s state
and current values in an
observable table
(see
“Creating observable property tables” on page 97
). This can
be the export-settings property table provided by the API, or a table that you create for local program data
that you define.
When you create a binding, the value or state of the UI element reflects the data value, and the data value
reflects the UI element state. This is a two-way relationship; when the binding is established, the data value
from the table is pushed to the view, and when the user changes the bound value in the view (by selecting
a checkbox, for instance, or entering a value in a text field), the table is notified and the corresponding
data key value or values change accordingly. Similarly, when your program changes a value in the table,
the bound UI elements are updated to display the new value.
To create bindings:
1.
Specify a bound table at some level of the view hierarchy. Set the table as the value of the
bind_to_object
property (you can also use the name
object
for this property). The bound table of a
parent container is inherited by its children, but can be overridden.
Z
When you create a dialog box, you must set the bound table explicitly.
Z
When you create a section for the Plug-in Manager or Export dialog using the
sectionsForTopOfDialog
or
sectionsForBottomOfDialog
functions, the settings table for
your plug-in is passed to those functions as the
propertyTable
value. This table contains both
export settings that you have defined for your plug-in (see
“Remembering user choices” on
page 57
) and Lightroom-defined export settings (see
“Lightroom built-in property keys” on
page 59
).
The
propertyTable
is automatically set as the default bound table for all of the UI elements in the
view hierarchy for that section. However, the bindable
synopsis
for the section is not part of the
view hierarchy; if you want to make that value dynamic, you must specify the table explicitly. See
“Adding custom sections to the Plug-in Manager” on page 32
.
Property
Datatype
Description
width_in_chars
number
Calculates the minimum width using this as the
number of m characters that should fit. Considered
together with
width_in_digits
. Default is 15 for
editable text fields.
width_in_digits
number
Calculates the minimum width using this as the
number of 0 digits that should fit. Considered
together with
width_in_chars
. Default is 0.
height_in_lines
number
Calculates the minimum height using this as the
number of lines that should fit within the field.
Default is 1.