# Inline event scripts

Files use JavaScript by default. Optionally place `scriptLanguage: "js"` or
`scriptLanguage: "lua"` before the definitions. There is no automatic language
detection. The setting applies to all components and screens in the file.

```qml
Dialog Counter {
    property int count
    Button {
        text: "Getippt: " + str(count)
        onTap: { state.count += 1; }
    }
}
```

```qml
scriptLanguage: "lua"
Dialog Counter {
    property int count
    Button {
        text: str(count)
        onTap: { state.count = state.count + 1 }
    }
}
```

Ordinary signal references such as `onTap: next` remain valid. Blocks are available
for native widget events and signals of custom components. `event.value` is the
event value; `event.text` is also provided for text and `event.checked` for Boolean
values. For component signals with multiple parameters, `event.args` contains the
values (zero-based in JS, one-based in Lua). `emit("signal", arguments...)` emits a
declared signal.

`state` reads the root properties; scalar arguments and state are writable
(`int`, `real`, `bool`, `string`, `color`). Constants, records, and lists are
read-only; image and node objects are not exposed. Colors are ARGB numbers, or
`#rrggbb`/`#aarrggbb` strings when writing. Unknown properties, incorrect types,
and invalid state names are rejected.

Handlers have 8 MiB of memory and a 20 ms execution budget. They run on the UI
thread; slow work belongs in C++ tasks. Changes and signals are committed only
after a successful call. Local script variables belong to the handler; UI state
belongs in `state`. Deleting the node disables its handler. Errors include the
AURA file and line, are logged and reported to `Context::onScriptError`; the
preview displays them as diagnostics. `AURA_WITH_SCRIPT=OFF` still builds the UI
but explicitly rejects inline handlers.
