# Export

The `cad-notepad` resource provides utility exports to manage the notepad UI, including toggling visibility and checking its open state.

#### `IsOpen`

Checks whether the notepad is currently open.

exports\['cad-notepad'\]:IsOpen()

**Returns:**

- `boolean` – `true` if the notepad is open, `false` otherwise.

**Usage:**

```lua
if exports['cad-notepad']:IsOpen() then
  print("Notepad is currently open")
end
```

---

#### `ToggleNotepad`

Toggles the notepad UI for the player. Optionally forces it open.

```lua
exports['cad-notepad']:ToggleNotepad(data, force)
```

**Parameters:**

- `data` _(table, optional)_ – Pass any relevant information for the notepad (e.g., prefilled content)

| Key | Type | Description |
| --- | --- | --- |
| `slot` | `number` | Slot index of the notepad |
| `paragraph` | `string` | Text content to display |
| `drawing` | `string` | JSON string of canvas drawing data |
| `signature` | `string` | Name or signature of the user |
| `coords` | `vector3` | (Optional) Position where note was created |
| `disabled` | `boolean` | If true, sets the notepad to read-only mode |
| `force` | `boolean` | (Optional) Force open, even if already open |

- `force` _(boolean, optional)_ – If `true`, forces the notepad to open regardless of current state.

**Example:**

```lua
exports['cad-notepad']:ToggleNotepad({
  slot = 0,
  paragraph = "Initial field notes for investigation.",
  signature = "Officer R. Singh",
  coords = vector3(-334.9, -1040.5, 76.88),
  drawing = "{\"lines\":[{\"points\":[{\"x\":83.70,\"y\":296.85},{\"x\":85.29,\"y\":295.26},{\"x\":91.46,\"y\":285.40}...],\"brushColor\":\"#161616\",\"brushRadius\":1}],\"width\":400,\"height\":400}",
  disabled = true
}, true)
```

---

#### Server → Client: `cad-notepad:toggle`

Triggers the notepad from the server side.

```lua
TriggerClientEvent('cad-notepad:toggle', source, data, force)
```

**Parameters:**

- `source` _(number)_ – Player's server ID.
- `data` _(table, optional)_ – Same as `ToggleNotepad`.
- `force` _(boolean, optional)_ – Force toggle on the client.

**Example:**

```lua
TriggerClientEvent('cad-notepad:toggle', src, { text = "Server-pushed note" }, true)
```
