# PopupWidget

**Noir.Classes.PopupWidget**: `NoirClass`

Represents a 3D space popup UI widget to be shown to players via UIService.

***

```lua
Noir.Classes.PopupWidget:Init(ID, visible, text, position, renderDistance, player)
```

Initializes a new popup widget.

### Parameters

* `ID`: number
* `visible`: boolean
* `text`: string
* `position`: SWMatrix
* `renderDistance`: number
* `player`: NoirPlayer|nil

***

```lua
Noir.Classes.PopupWidget:AttachToBody(body)
```

Attaches this popup to a body.

Upon doing so, the popup will follow the body's position until detached with the `:Detach()` method.

You can offset the popup from the body by setting the `AttachmentOffset` property.

Note that `:Update()` is called automatically.

### Parameters

* `body`: NoirBody

***

```lua
Noir.Classes.PopupWidget:AttachToObject(object)
```

Attaches this popup to an object.

Upon doing so, the popup will follow the object's position until detached with the `:Detach()` method.

You can offset the popup from the object by setting the `AttachmentOffset` property.

Note that `:Update()` is called automatically.

### Parameters

* `object`: NoirObject

***

```lua
Noir.Classes.PopupWidget:Detach()
```

Detaches this popup from any body or object.

***

```lua
Noir.Classes.PopupWidget:_Serialize() ---@diagnostic disable-next-line missing-return
```

Serializes this popup widget.

### Returns

* `NoirSerializedPopupWidget`

***

```lua
Noir.Classes.PopupWidget:Deserialize(serializedWidget)
```

Deserializes a popup widget.

### Parameters

* `serializedWidget`: NoirSerializedPopupWidget

### Returns

* `NoirPopupWidget|nil`

***

```lua
Noir.Classes.PopupWidget:_Update()
```

Handles updating this widget.

***

```lua
Noir.Classes.PopupWidget:_Destroy()
```

Handles destroying this widget.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cuhhub.gitbook.io/noir/api-reference/built-ins/classes/widgets/popupwidget.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
