Adobe 12040118 Using Help - Page 206

Modal dialogs, Warning

Page 206 highlights

Adobe After Effects Help Using Help Creating User Interface Elements Back 206 Modal dialogs A modal dialog is initially invisible. When calling its show() method, the dialog is displayed and starts executing. The call to show() does not return until the dialog has been dismissed, typically by the user clicking an OK or Cancel button. When calling the hide() or close() methods during the execution of a modal dialog, the dialog is dismissed. The close() method accepts an optional argument that the call to show() returns. Warning: You cannot use the JavaScript Debugger to debug event callback functions for modal dialogs, because once the dialog starts executing, it captures all mouse events. Setting a breakpoint in an event callback function for a modal dialog will result in an apparent application hang if the breakpoint is ever reached. To work around this restriction, an effective debugging technique is to create your dialog, but not call its show() method to make it visible. Then use the debugger to call the notify() method on controls whose event callback functions you wish to debug. It's considered good design practice to keep the code in the event callback functions simple, while deferring the primary script logic execution until after the dialog has been dismissed. Default and Cancel elements Modal dialogs can usually be dismissed by typing certain keyboard shortcuts. In addition to clicking the 'OK' or 'Cancel' buttons, typing the 'Enter' key normally produces the same results as clicking the 'OK' (or default) button, and typing the 'Esc' key is equivalent to clicking the 'Cancel' button. In each case, the keyboard shortcut is the same as if your script had called the notify() method for the associated Button. The dialog designer has explicit control over which Button elements are notified by these keyboard shortcuts: a newlycreated dialog has defaultElement and cancelElement properties that are initially undefined. The dialog designer can set these properties to the objects representing the buttons that should be notified when the respective keyboard shortcut is typed. The scripting user interface provides reasonable defaults if the defaultElement and cancelElement properties are still undefined when the dialog is about to be shown for the first time. Default values for the defaultElement property are determined by the following algorithm: • The scripting user interface searches the dialog's buttons for a button whose name property has the string value "ok" (case is not important). If one is found, defaultElement is set to that object. • If no matching named object is found, the scripting user interface searches the dialog's buttons for a button whose text property has the string value "ok" (case is not important). If one is found, defaultElement is set to that object. Default value for the cancelElement property are determined by the following algorithm: • The scripting user interface searches the dialog's buttons for a button whose name property has the string value "cancel" (case is not important). If one is found, cancelElement is set to that object. • If no matching named object is found, the scripting user interface searches the dialog's buttons for a button whose text property has the string value "cancel" (case is not important). If one is found, cancelElement is set to that object. These algorithms handle most dialog boxes without the designer having to explicitly set these properties. When you add buttons to a dialog that will be used to dismiss the dialog, use creation properties to set the name property of such buttons to 'ok' or 'cancel', depending on the desired semantics; this precaution makes the above algorithm work properly even when the text of such buttons is localized. If the scripting user interface cannot find a matching button for either case, the respective property is set to null, which means that keyboard shortcuts for default or cancel will not notify any elements. Using Help Back 206

  • 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
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253

U
sing H
elp
B
ack
206
Adobe After Effects Help
Creating User Interface Elements
U
sing H
elp
B
ack
206
Modal dialogs
A modal dialog is initially invisible. When calling its
show()
method, the dialog is displayed and starts
executing. The call to
show()
does not return until the dialog has been dismissed, typically by the user clicking
an OK or Cancel button.
When calling the
hide()
or c
lose()
methods during the execution of a modal dialog, the dialog is dismissed.
The
close()
method accepts an optional argument that the call to
show()
returns.
Warning
: You cannot use the JavaScript Debugger to debug event callback functions for modal dialogs, because
once the dialog starts executing, it captures all mouse events. Setting a breakpoint in an event callback function for
a modal dialog will result in an apparent application hang if the breakpoint is ever reached.
To work around this restriction, an effective debugging technique is to create your dialog, but not call its show()
method to make it visible. Then use the debugger to call the notify() method on controls whose event callback
functions you wish to debug. It’s considered good design practice to keep the code in the event callback functions
simple, while deferring the primary script logic execution until after the dialog has been dismissed.
Default and Cancel elements
Modal dialogs can usually be dismissed by typing certain keyboard shortcuts. In addition to clicking the ‘OK’
or ‘Cancel’ buttons, typing the ‘Enter’ key normally produces the same results as clicking the ‘OK’ (or default)
button, and typing the ‘Esc’ key is equivalent to clicking the ‘Cancel’ button. In each case, the keyboard
shortcut is the same as if your script had called the
notify()
method for the associated
Button
. The dialog
designer has explicit control over which
Button
elements are notified by these keyboard shortcuts: a newly-
created dialog has
defaultElement
and
cancelElement
properties that are initially undefined. The dialog
designer can set these properties to the objects representing the buttons that should be notified when the
respective keyboard shortcut is typed.
The scripting user interface provides reasonable defaults if the
defaultElement
and
cancelElement
properties
are still undefined when the dialog is about to be shown for the first time.
Default values for the
defaultElement
property are determined by the following algorithm:
The scripting user interface searches the dialog’s buttons for a button whose name property has the string
value “ok” (case is not important). If one is found,
defaultElement
is set to that object.
If no matching named object is found, the scripting user interface searches the dialog’s buttons for a button
whose
text
property has the string value “ok” (case is not important). If one is found,
defaultElement
is set
to that object.
Default value for the
cancelElement
property are determined by the following algorithm:
The scripting user interface searches the dialog’s buttons for a button whose name property has the string
value “cancel” (case is not important). If one is found,
cancelElement
is set to that object.
If no matching named object is found, the scripting user interface searches the dialog’s buttons for a button
whose
text
property has the string value “cancel” (case is not important). If one is found,
cancelElement
is
set to that object.
These algorithms handle most dialog boxes without the designer having to explicitly set these properties.
When you add buttons to a dialog that will be used to dismiss the dialog, use
creation properties
to set the
name
property of such buttons to ‘ok’ or ‘cancel’, depending on the desired semantics; this precaution makes the
above algorithm work properly even when the
text
of such buttons is localized. If the scripting user interface
cannot find a matching button for either case, the respective property is set to
null
, which means that keyboard
shortcuts for default or cancel will not notify any elements.