Adobe 65007312 Programming Guide - Page 112

Changing the contents of a view dynamically

Page 112 highlights

CHAPTER 5: Creating a User Interface for Your Plug-in Determining layout 112 spacing = f:label_spacing(), f:static_text { title = "Occupation:", alignment = "right", width = LrView.share "label_width", -- the shared binding }, f:edit_field { width_in_chars = 20, }, }, } local result = LrDialogs.presentModalDialog( -- invoke the dialog { title = "Dialog Example", contents = contents, } ) end ) Changing the contents of a view dynamically This simple example of dynamic layout shows one set of controls and hides another set, based on the selected value in a pop-up menu. The dialog contains the popup and three views, each containing an alternate set of controls. When the user makes a selection in the pop-up menu, one of the views is shown, and the other two are hidden. For example: This technique makes use of the overlapping placement style, and demonstrates binding of a property in one node to a property in another, so that changing one also changes the other. The overlapping value for the place property causes all of the children of a node to be placed in the same space. The parent views are made big enough to enclose the largest child in any view, and all of the children are placed within that space. If all of the children were visible at the same time, they would display on top of one another. To make sure only one view is visible at a time, we bind the visible value of each alternative view to a unique value of the pop-up menu. When the user makes the selection that has this value, the view bound to that value is shown, and the other views (bound to different values) are hidden. X You only need to set the visibility of the parent view; when the parent is hidden, all of its child nodes are also hidden, regardless of their individual visibility settings. X The LrBindings.whenKeyEquals() function sets visible to true only when the specified value of the bound property is set. You could choose to bind the true value to, for example, a logical OR or AND of several key values.

  • 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
Determining layout
112
spacing = f:label_spacing(),
f:static_text {
title = "Occupation:",
alignment = "right",
width = LrView.share "label_width", -- the shared binding
},
f:edit_field {
width_in_chars = 20,
},
},
}
local result = LrDialogs.presentModalDialog( -- invoke the dialog
{
title = "Dialog Example",
contents = contents,
}
)
end )
Changing the contents of a view dynamically
This simple example of dynamic layout shows one set of controls and hides another set, based on the
selected value in a pop-up menu. The dialog contains the popup and three views, each containing an
alternate set of controls. When the user makes a selection in the pop-up menu, one of the views is shown,
and the other two are hidden. For example:
This technique makes use of the
overlapping
placement style, and demonstrates
binding
of a property in
one node to a property in another, so that changing one also changes the other.
The
overlapping
value for the
place
property causes all of the children of a node to be placed in the
same space. The parent views are made big enough to enclose the largest child in any view, and all of the
children are placed within that space.
If all of the children were visible at the same time, they would display on top of one another. To make sure
only one view is visible at a time, we bind the
visible
value of each alternative view to a unique value of
the pop-up menu. When the user makes the selection that has this value, the view bound to that value is
shown, and the other views (bound to different values) are hidden.
X
You only need to set the visibility of the parent view; when the parent is hidden, all of its child nodes
are also hidden, regardless of their individual visibility settings.
X
The
LrBindings.whenKeyEquals()
function sets
visible
to true only when the specified value of
the bound property is set. You could choose to bind the true value to, for example, a logical OR or AND
of several key values.