textarea Component
Use the textarea component to display static or editable text content.
{
"type": "textarea",
"text": "Hello!",
}
The textarea fires events for both text changed and typing stopped, and has various functions for moving the cursor and scrolling.
TipIt's good practice to use the
sizeshared constraint to set a desired size for this layout. This acts like a minimum size in a layout.
Properties
- bordertype
- ENUM
- Default:
"none"
Set the border type of this Text Area.
| Value | Description |
|---|---|
"bezel" |
Use a bezelled border. |
"solid" |
Use a solid border. |
"none" |
No border. |
- behaviour
- OBJECT
Tweak the behaviour when text is added programatically.
- mode
- ENUM
- Default:
"replace"
How to add the specified text.
| Value | Description |
|---|---|
"replace" |
Replace all the text. |
"append" |
Append the text to the end of the current text. |
"prepend" |
Prepend the text to the start of the current text. |
"replacelast" |
Replace the last set text with the new text. |
- scroll
- ENUM
- Default:
"none"
The scroll behaviour after setting text based on the mode.
| Value | Description |
|---|---|
"none" |
Don't scroll on setting text. |
"auto" |
Automatically scroll on setting text. |
"start" |
Scroll to the start of the document on setting text. |
"end" |
Scroll to the end of the document on setting text. |
- autoadjustcontentinsets
- BOOL
- Default:
true
Automatically adjusts the scroll view's internal content insets property to account for any overlapping title bar.
Useful if you are using external Alfred UIs with transparent title bar and full size content views.
- disableallsubstitutions
- BOOL
- Default:
"false"
By default, a text area will use the macOS user-configured substitution options for a text area.
Set to true to disable the substitution options for this text view e.g. smart quotes, spell checking, dashes.
Also see Shared Properties.
Event Triggers
This component dispatches the following event triggers:
| Trigger | Description |
|---|---|
"changed" |
When the text changes via user input. |
"typingstopped" |
When the user stops typing in the textarea. |
TipIf you are running a complex script, it's best to use the
"typingstopped"event.
Functions
Perform actions directly on this textarea using the functions Action.
Examples
Speak the contents when typing stops
This example also overrides the default desired size to 300x300px.
{
"constraints": {
"size": {
"width": 300,
"height": 300
}
},
"type": "textarea",
"text": "Hello!",
"events": [
{
"triggers": "typingstopped",
"action": {
"type": "json",
"variables": {
"tospeak": "{value:self.text}"
},
"src": {
"speak": {
"text": "{var:tospeak}"
}
}
}
}
]
}