Adobe 65007312 Programming Guide - Page 177

The two sliders are now bound to different keys in different tables; the user can change the numeric

Page 177 highlights

CHAPTER 9: Getting Started: A Tutorial Example Binding to multiple keys 177 } }, }, value = LrView.bind( "sliderTwo" ), width_in_digits = 7 f:group_box { fill_horizontal = 1, title = "Both Values", font = "", f:edit_field{ place_horizontal = 0.5, value = LrView.bind { -- Supply a table with table keys. keys = { { -- Only the key name is needed as sliderOne -- in tableOne and that is already bound. key = "sliderOne" }, { -- Supply the key and the table to which it belongs. key = "sliderTwo", bind_to_object = tableTwo } }, -- This operation creates the value for this edit_field. -- The bound values are accessed with the arg 'values'. operation = function( _, values, _ ) return values.sliderTwo + values.sliderOne end }, width_in_digits = 7 }, } } 6. For the value binding in the second slider, we will specify a different bound table, which overrides the default bound table for that control: f:slider { bind_to_object = tableTwo, value = LrView.bind( "sliderTwo" ), 7. Do the same for the edit box in this group: f:edit_field { bind_to_object = tableTwo, value = LrView.bind( "sliderTwo" ), The two sliders are now bound to different keys in different tables; the user can change the numeric values using the sliders, and you can see the result in the associated text field for each one. You will now add code to bind a third text box to a value derived from these two values. 8. To bind a value to multiple keys in different tables, you need to supply both the key name and the table in the binding, since the control can have only one default bound table. Add this code to bind the value of the third edit box:

  • 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
9: Getting Started: A Tutorial Example
Binding to multiple keys
177
value = LrView.bind( "sliderTwo" ),
width_in_digits = 7
}
},
},
f:group_box {
fill_horizontal = 1,
title = "Both Values",
font = "<system>",
f:edit_field{
place_horizontal = 0.5,
value = LrView.bind {
-- Supply a table with table keys.
keys = {
{
-- Only the key name is needed as sliderOne
-- in tableOne and that is already bound.
key = "sliderOne"
},
{
-- Supply the key and the table to which it belongs.
key = "sliderTwo",
bind_to_object = tableTwo
}
},
-- This operation creates the value for this edit_field.
-- The bound values are accessed with the arg 'values'.
operation = function( _, values, _ )
return values.sliderTwo + values.sliderOne
end
},
width_in_digits = 7
},
}
}
6.
For the
value
binding in the second slider, we will specify a different bound table, which overrides the
default bound table for that control:
f:slider {
bind_to_object = tableTwo,
value = LrView.bind( "sliderTwo" ),
7.
Do the same for the edit box in this group:
f:edit_field {
bind_to_object = tableTwo,
value = LrView.bind( "sliderTwo" ),
The two sliders are now bound to different keys in different tables; the user can change the numeric
values using the sliders, and you can see the result in the associated text field for each one.
You will now add code to bind a third text box to a value derived from these two values.
8.
To bind a value to multiple keys in different tables, you need to supply both the key name and the
table in the binding, since the control can have only one default bound table.
Add this code to bind the value of the third edit box: