> For the complete documentation index, see [llms.txt](https://lua2.fatality.win/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lua2.fatality.win/api/instances/gui/control/window.md).

# Window

This type represents a window control.

{% hint style="info" %}
This type inherits [`Control`](/api/instances/gui/control.md) type. All of its base methods and fields are also available in this type.
{% endhint %}

## Retrieve <a href="#call" id="call"></a>

This type doesn't have a constructor and there's only one window, which can be retrieved like this:

```lua
local wnd = gui.GetMainWindow()
```

If you wish to create new windows, look into [`LuaPopupControl`](/api/instances/gui/control/luapopupcontrol.md) instead.

***

## AddTab <a href="#get-value" id="get-value"></a>

[<kbd><mark style="background-color:purple;">**Method**<mark style="background-color:purple;"></kbd>](#user-content-fn-1)[^1]

Adds a new tab to the menu.

{% hint style="info" %}
Tabs usually have a layout that supports only three group columns. You may use a custom [`Layout`](/api/instances/gui/container/controlcontainer/layout.md) with tab layout mode `NONE` to bypass this restriction.
{% endhint %}

**Arguments**

| Name         | Type                                                                  | Description      |
| ------------ | --------------------------------------------------------------------- | ---------------- |
| `id`         | [`ControlID`](/api/instances/gui/types/controlid.md)`\|string`        | ID.              |
| `icon`       | [`Texture`](/api/instances/draw/managed/texture.md)                   | Tab icon.        |
| `title`      | `string`                                                              | Tab name.        |
| `layoutMode` | [`TabLayoutMode`](/api/instances/gui/control/window/tablayoutmode.md) | Tab layout mode. |

**Returns**

| Type                                                                                                                          | Description                                                             |
| ----------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| [`Container`](/api/instances/gui/container.md) \| [`TabsLayout`](/api/instances/gui/container/controlcontainer/tabslayout.md) | The new tab container, or subtab container if `layoutMode` is `SUBTABS` |

Example (subtabs)

```lua
local wnd = gui.GetMainWindow()
local tab = wnd:AddTab('my_tab', draw.textures['gui_icon_down'], 'My tab', gui.TabLayoutMode.SUBTABS)
local subtab = tab:AddTab('my_subtab', 'My subtab', gui.TabLayoutMode.DEFAULT, true)
local group = gui.Group('my_group', 'My group', 120, gui.GroupWidthMode.REDUCED)

subtab:Add(group)
```

Example (no subtabs)

```lua
local wnd = gui.GetMainWindow()
local tab = wnd:AddTab('my_tab', draw.textures['gui_icon_down'], 'My tab', gui.TabLayoutMode.DEFAULT)
local group = gui.Group('my_group', 'My group', 120, gui.GroupWidthMode.FULL)

tab:Add(group)
```

[^1]: This field is a method and must be invoked using a colon (:)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://lua2.fatality.win/api/instances/gui/control/window.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
