|
| 1 | +## app.clipboard |
| 2 | + |
| 3 | +A set of functions to handle the clipboard. |
| 4 | + |
| 5 | +When calling a function with clipboard write access in a script, Aseprite will ask the user if they want to allow the function to run or stop the script. |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | +## app.clipboard.text |
| 10 | + |
| 11 | +```lua |
| 12 | +local text = app.clipboard.text |
| 13 | +``` |
| 14 | + |
| 15 | +Gets or sets the clipboard text. Returns `nil` if there is no text. |
| 16 | + |
| 17 | +## app.clipboard.image |
| 18 | + |
| 19 | +```lua |
| 20 | +local image = app.clipboard.image |
| 21 | +``` |
| 22 | + |
| 23 | +Gets or sets the clipboard [image](image.md#image). Returns `nil` if there is no image. |
| 24 | + |
| 25 | +## app.clipboard.content |
| 26 | + |
| 27 | +```lua |
| 28 | +local content = app.clipboard.content |
| 29 | +``` |
| 30 | + |
| 31 | +Gets the content of the clipboard, as a table. Values: |
| 32 | + |
| 33 | +* `image`: An [image](image.md#image) object or `nil` |
| 34 | +* `selection`: A [selection](selection.md#selection) object or `nil` |
| 35 | +* `palette`: A [palette](palette.md#palette) object or `nil` |
| 36 | +* `tileset`: A [tileset](tileset.md#tileset) object or `nil` |
| 37 | +* `text`: A string or `nil` |
| 38 | + |
| 39 | +Depending on what is copied, each value will be set differently. Case table: |
| 40 | + |
| 41 | +| |An image is copied in Aseprite |An image is copied externally|Text is copied|A portion of the Palette is copied | |
| 42 | +|-------------|------------------------------------|-----------------------------|--------------|---------------------------------------------------------| |
| 43 | +|`image` |[Image](image.md#image) |[Image](image.md#image) |`nil` |`nil` | |
| 44 | +|`selection`|[Selection](selection.md#selection) |`nil` |`nil` |`nil` | |
| 45 | +|`palette` |Sprite [palette](palette.md#palette)|`nil` |`nil` |`nil` | |
| 46 | +|`tileset` |`nil` |`nil` |`nil` |`nil` | |
| 47 | +|`text` |`nil` |`nil` |String |String of selected colors in hex codes, seperated by `\n`| |
| 48 | + |
| 49 | +## app.clipboard.hasText |
| 50 | + |
| 51 | +```lua |
| 52 | +local hasText = app.clipboard.hasText |
| 53 | +``` |
| 54 | + |
| 55 | +Returns true if the last item copied to the clipboard was text. |
| 56 | + |
| 57 | +## app.clipboard.hasImage |
| 58 | + |
| 59 | +```lua |
| 60 | +local hasImage = app.clipboard.hasImage |
| 61 | +``` |
| 62 | + |
| 63 | +Returns true if the last item copied to the clipboard was an [image](image.md#image). |
| 64 | + |
| 65 | +## app.clipboard.clear() |
| 66 | + |
| 67 | +```lua |
| 68 | +app.clipboard.clear() |
| 69 | +``` |
| 70 | + |
| 71 | +Clears the clipboard. |
0 commit comments