|
| 1 | +# Dropdown Menus |
| 2 | + |
| 3 | +This category contains information relating to dropdown menu properties. |
| 4 | + |
| 5 | +!!! note |
| 6 | + These APIs were added in After Effects (Beta) 26.0 and are subject to change while they remain in Beta. |
| 7 | + |
| 8 | +In expressions, the `.value` of a dropdown menu is returned as an index (a number). This is true of both customized Menu properties of Dropdown Menu Controls and dropdown menus of other effects and layers. **The strings in dropdown menu properties of effects and layers are also accessible via the properties/methods below.** |
| 9 | + |
| 10 | +On this page, `effect("Dropdown Menu Control")("Menu")` is used as a sample on how to call these items; however, note that any method that returns a dropdown menu [Property](../objects/property.md) will work. |
| 11 | + |
| 12 | +**Notes** |
| 13 | + |
| 14 | +- These APIs are available only in expressions using the JavaScript expression engine. |
| 15 | + |
| 16 | +- The text of `Layer Control` dropdowns is not accessible with these APIs. If you need the selected layer's name, you can use the `.name` property of the layer returned by the Layer Control. |
| 17 | + |
| 18 | +!!! warning |
| 19 | + We recommend continuing to use the index of dropdown menus when driving expression logic (versus matching the strings), since indexes will remain unchanged when the language of After Effects changes. |
| 20 | + |
| 21 | +--- |
| 22 | + |
| 23 | +## Attributes |
| 24 | + |
| 25 | +### items |
| 26 | + |
| 27 | +`effect("Dropdown Menu Control")("Menu").items` |
| 28 | + |
| 29 | +#### Description |
| 30 | + |
| 31 | +Returns an array of all the text strings in a dropdown menu property. |
| 32 | + |
| 33 | +#### Type |
| 34 | + |
| 35 | +Array of Strings |
| 36 | + |
| 37 | +#### Example |
| 38 | + |
| 39 | +**Show all the strings in a dropdown on separate lines:** |
| 40 | + |
| 41 | +```js |
| 42 | +const menu = effect("Dropdown Menu Control")("Menu"); |
| 43 | +const allStrings = menu.items; |
| 44 | + |
| 45 | +allStrings.join("\n"); |
| 46 | +``` |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +### text |
| 51 | + |
| 52 | +`effect("Dropdown Menu Control")("Menu").text` |
| 53 | + |
| 54 | +#### Description |
| 55 | + |
| 56 | +Returns the currently-active text string of a dropdown menu property at the current time. |
| 57 | + |
| 58 | +#### Type |
| 59 | + |
| 60 | +String |
| 61 | + |
| 62 | +#### Example |
| 63 | + |
| 64 | +**Show the selected dropdown text directly in a Text layer:** |
| 65 | + |
| 66 | +```js |
| 67 | +effect("Dropdown Menu Control")("Menu").text; |
| 68 | +``` |
| 69 | + |
| 70 | +**Show the current Fractal Type from the native Fractal Noise effect:** |
| 71 | + |
| 72 | +```js |
| 73 | +effect("ADBE Fractal Noise")("ADBE Fractal Noise-0001").text; |
| 74 | +``` |
| 75 | + |
| 76 | +--- |
| 77 | + |
| 78 | +## Methods |
| 79 | + |
| 80 | +### textAtTime() |
| 81 | + |
| 82 | +`effect("Dropdown Menu Control")("Menu").textAtTime(time)` |
| 83 | + |
| 84 | +#### Description |
| 85 | + |
| 86 | +Returns the text string of a dropdown menu property at the specified time, in seconds. |
| 87 | + |
| 88 | +This is effectively the same as how `valueAtTime()` relates to `value`, in that `text` will always return the dropdown string as the current time, and `timeAtTime()` can return the string at a specific time. |
| 89 | + |
| 90 | +#### Parameters |
| 91 | + |
| 92 | +| Parameter | Type | Description | |
| 93 | +| --------- | ------ | ------------------------------------------------- | |
| 94 | +| `time` | Number | The time, in seconds, to get the text string from | |
| 95 | + |
| 96 | +#### Returns |
| 97 | + |
| 98 | +String |
| 99 | + |
0 commit comments