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.

Tip

It's good practice to use the size shared constraint to set a desired size for this layout. This acts like a minimum size in a layout.

Properties

background
COLOUR | null
null removes the background

The background COLOUR.

font
FONT | null
null sets the default font

The FONT for this label's text.

colour
COLOUR | null
null sets the default text colour

The text COLOUR.

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.
editable
BOOL

If the text in this text area is editable.

selectable
BOOL

If the text in this text area is selectable.

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.

text
STRING [getter]

The text for this text area.

textinsets
OBJECT

A horizontal and vertical inset around the text.

horizontal
INTEGER
Default: 0, Range: 0-64

The inset on the left and right of the text.

vertical
INTEGER
Default: 0, Range: 0-64

The inset at the top and bottom of the text.

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.
Tip

If 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.

scrolltop

Scroll to the top of the text area.

scrollbottom

Scroll to the bottom of the text area.

caretstart

Move the caret to the start of the text.

caretend

Move the caret to the end of the text.

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}"
          }
        }
      }
    }
  ]
}