# ScriptTrigger

`com.jsmacrosce.jsmacros.core.config.ScriptTrigger`

Mutable trigger configuration used by listeners; constructing one does not register a listener or run a script.  
 ```js
const Trigger = Java.type("com.jsmacrosce.jsmacros.core.config.ScriptTrigger");  
const Type = Java.type("com.jsmacrosce.jsmacros.core.config.ScriptTrigger$TriggerType");  
const Path = Java.type("java.nio.file.Path");  
const trigger = new Trigger(Type.EVENT, "Tick", Path.of("script.js"), false, false);  
Chat.log(trigger.getEvent());  
 ```

## Nested types

- [TriggerType](ScriptTrigger.TriggerType.md)

## Constructors

### new ScriptTrigger {#com.jsmacrosce.jsmacros.core.config.ScriptTrigger_constructor-ScriptTrigger.TriggerType-String-Path-boolean-boolean-}

```js
new ScriptTrigger(ScriptTrigger.TriggerType triggerType, String event, Path scriptFile, boolean enabled, boolean joinRequested)
```

Initializes the trigger configuration; the path is stringified and reconstructed by the other constructor.

**Parameters:**
- `triggerType`: dispatch mode
- `event`: event name or key/modifier combination
- `scriptFile`: configured script path
- `enabled`: whether listener execution is allowed
- `joinRequested`: whether to request joined handling where supported

## Fields

### enabled {#com.jsmacrosce.jsmacros.core.config.ScriptTrigger_enabled}

```js
enabled: boolean
```

Whether listener execution is allowed. A change is visible to dispatch on other threads and
 does not stop an in-flight run.

### event {#com.jsmacrosce.jsmacros.core.config.ScriptTrigger_event}

```js
event: String
```

Event name, or key and modifier combination for key triggers.

### joinRequested {#com.jsmacrosce.jsmacros.core.config.ScriptTrigger_joinRequested}

```js
joinRequested: boolean
```

Whether joined handling is requested where the event supports it.

**Since:** 2.2.0

### scriptFile {#com.jsmacrosce.jsmacros.core.config.ScriptTrigger_scriptFile}

```js
scriptFile: Path
```

Configured script path.

### triggerType {#com.jsmacrosce.jsmacros.core.config.ScriptTrigger_triggerType}

```js
triggerType: ScriptTrigger.TriggerType
```

Selects event-name dispatch or a key-event mode.

## Methods

### copy {#com.jsmacrosce.jsmacros.core.config.ScriptTrigger_copy-ScriptTrigger-}

```js
static copy(ScriptTrigger m): ScriptTrigger
```

Copies a trigger's configuration into a new instance.

**Parameters:**
- `m`: trigger to copy

**Returns:** new trigger with the same configuration

### copy {#com.jsmacrosce.jsmacros.core.config.ScriptTrigger_copy-}

```js
copy(): ScriptTrigger
```

Returns a new trigger with this instance's configuration.

**Returns:** new trigger with the same configuration

### equals {#com.jsmacrosce.jsmacros.core.config.ScriptTrigger_equals-ScriptTrigger-}

```js
equals(ScriptTrigger macro): boolean
```

Compares trigger type, case-insensitive event text, and path; enabled and joinRequested are ignored.

**Parameters:**
- `macro`: trigger to compare

**Returns:** whether those three configuration values match

### equals {#com.jsmacrosce.jsmacros.core.config.ScriptTrigger_equals-Object-}

```js
equals(Object arg0): boolean
```

**Returns:** `boolean`

### getEnabled {#com.jsmacrosce.jsmacros.core.config.ScriptTrigger_getEnabled-}

```js
getEnabled(): boolean
```

Returns whether this trigger is enabled.

**Returns:** `true` when enabled

**Since:** 1.2.7

### getEvent {#com.jsmacrosce.jsmacros.core.config.ScriptTrigger_getEvent-}

```js
getEvent(): String
```

Returns the event or key identifier associated with this trigger.

**Returns:** the configured event/key name

**Since:** 1.2.7

### getScriptFile {#com.jsmacrosce.jsmacros.core.config.ScriptTrigger_getScriptFile-}

```js
getScriptFile(): String
```

Returns the script file path as a string.

**Returns:** the path's string representation

**Since:** 1.2.7

### getScriptPath {#com.jsmacrosce.jsmacros.core.config.ScriptTrigger_getScriptPath-}

```js
getScriptPath(): Path
```

Returns the configured script path.

**Returns:** the script path

**Since:** 2.1.0

### getTriggerType {#com.jsmacrosce.jsmacros.core.config.ScriptTrigger_getTriggerType-}

```js
getTriggerType(): ScriptTrigger.TriggerType
```

Returns this trigger's type.

**Returns:** the configured trigger type

**Since:** 1.2.7

### setEnabled {#com.jsmacrosce.jsmacros.core.config.ScriptTrigger_setEnabled-boolean-}

```js
setEnabled(boolean enabled): void
```

Enables or disables this trigger for future dispatches. The trigger stays registered, so the
 macro editor can enable it again, and the change is written to the profile on the next save.  
 A run that is already in progress is not stopped.

**Parameters:**
- `enabled`: whether listener execution is allowed

**Since:** 2.2.0

### toString {#com.jsmacrosce.jsmacros.core.config.ScriptTrigger_toString-}

```js
toString(): String
```

Returns a diagnostic description of the configured type, event, path, enabled flag, and join-request flag; this is not a serialization format.

**Returns:** diagnostic description
