# OverlayContainer

`com.jsmacrosce.wagyourgui.overlays.OverlayContainer`

A container that hosts nested overlays and delegates overlay operations through its parent.

## Constructors

### new OverlayContainer {#com.jsmacrosce.wagyourgui.overlays.OverlayContainer_constructor-int-int-int-int-Font-IOverlayParent-}

```js
new OverlayContainer(int x, int y, int width, int height, Font textRenderer, IOverlayParent parent)
```

Stores the overlay geometry, font, and parent without initializing, opening or registering widgets.

**Parameters:**
- `x`: left coordinate in GUI space
- `y`: top coordinate in GUI space
- `width`: width in GUI units
- `height`: height in GUI units
- `textRenderer`: non-null font for subclass use
- `parent`: non-null parent for widget registration and overlay routing

## Fields

### savedBtnStates {#com.jsmacrosce.wagyourgui.overlays.OverlayContainer_savedBtnStates}

```js
savedBtnStates: Map<AbstractWidget, Boolean>
```

Mutable, replaceable map of hosting widgets to their saved active states, populated by standard hosts when opening this overlay with button disabling enabled.  
 Opening merges entries; initialization and closing do not clear them. Keep the map and stored Boolean values non-null for restoration.  
 Changes affect later restoration, but do not register widgets or immediately change their active states.

### scroll {#com.jsmacrosce.wagyourgui.overlays.OverlayContainer_scroll}

```js
scroll: Scrollbar
```

Optional scroll control, initially null, used by standard screen hosts to forward wheel input to their direct overlay.  
 Assigning it does not register or replace widgets.

## Methods

### close {#com.jsmacrosce.wagyourgui.overlays.OverlayContainer_close-}

```js
close(): void
```

Requests that this overlay be closed through its parent.

### closeOverlay {#com.jsmacrosce.wagyourgui.overlays.OverlayContainer_closeOverlay-OverlayContainer-}

```js
closeOverlay(OverlayContainer overlay): void
```

Closes the matching direct child overlay, removes its buttons, restores saved active states, and calls its [onClose()](#com.jsmacrosce.wagyourgui.overlays.OverlayContainer_onClose-) hook.

**Parameters:**
- `overlay`: the direct child overlay to close

### extractRenderState {#com.jsmacrosce.wagyourgui.overlays.OverlayContainer_extractRenderState-GuiGraphicsExtractor-int-int-float-}

```js
extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a): void
```

Forwards render-state extraction to tracked widgets in live list order, then this container's direct child overlay if present.  
 Does not submit the background automatically or check the stored container visibility flag; each widget applies its own extraction behavior.

**Parameters:**
- `graphics`: graphics context passed to widgets and the child overlay
- `mouseX`: mouse x-coordinate in GUI space
- `mouseY`: mouse y-coordinate in GUI space
- `a`: frame value forwarded to widgets and the child overlay

### getChildOverlay {#com.jsmacrosce.wagyourgui.overlays.OverlayContainer_getChildOverlay-}

```js
getChildOverlay(): OverlayContainer
```

Returns the deepest child overlay, or this container when it has no child.

**Returns:** the deepest child overlay, or this container if there is no child

### getFirstOverlayParent {#com.jsmacrosce.wagyourgui.overlays.OverlayContainer_getFirstOverlayParent-}

```js
getFirstOverlayParent(): IOverlayParent
```

Returns this container as the first overlay parent.

**Returns:** this overlay container

### keyPressed {#com.jsmacrosce.wagyourgui.overlays.OverlayContainer_keyPressed-KeyEvent-}

```js
keyPressed(KeyEvent keyEvent): boolean
```

Forwards the key press to this container's child overlay, if present.

**Parameters:**
- `keyEvent`: the key press event

**Returns:** `false`

### onClick {#com.jsmacrosce.wagyourgui.overlays.OverlayContainer_onClick-MouseButtonEvent-boolean-}

```js
onClick(MouseButtonEvent buttonEvent, boolean doubleClick): void
```

Forwards the click to this container's direct child overlay, if present; otherwise does nothing.

**Parameters:**
- `buttonEvent`: native click event forwarded unchanged to the child
- `doubleClick`: caller-supplied double-click flag forwarded unchanged; not computed here

### onClose {#com.jsmacrosce.wagyourgui.overlays.OverlayContainer_onClose-}

```js
onClose(): void
```

No-op extension hook called by standard hosts after widget removal and active-state restoration, before clearing the matching child reference.  
 This base implementation does not close the overlay or clear its tracked widgets, saved states or child reference.

### openOverlay {#com.jsmacrosce.wagyourgui.overlays.OverlayContainer_openOverlay-OverlayContainer-}

```js
openOverlay(OverlayContainer overlay): void
```

Opens the child overlay, disabling this container's buttons by default.

**Parameters:**
- `overlay`: the child overlay to open

### openOverlay {#com.jsmacrosce.wagyourgui.overlays.OverlayContainer_openOverlay-OverlayContainer-boolean-}

```js
openOverlay(OverlayContainer overlay, boolean disableButtons): void
```

Opens a child overlay at the deepest open level; optionally disables this container's buttons and saves their active states.

**Parameters:**
- `overlay`: the child overlay to open
- `disableButtons`: whether to disable this container's buttons and save their active states

### removeWidget {#com.jsmacrosce.wagyourgui.overlays.OverlayContainer_removeWidget-GuiEventListener-}

```js
removeWidget(GuiEventListener btn): void
```

Removes the first matching local tracked entry, then delegates the widget to the parent even if it was not tracked locally.  
 Duplicate local entries can remain; a parent failure does not roll back the local removal.

**Parameters:**
- `btn`: widget or listener to remove

### renderBackground {#com.jsmacrosce.wagyourgui.overlays.OverlayContainer_renderBackground-GuiGraphicsExtractor-}

```js
renderBackground(GuiGraphicsExtractor drawContext): void
```

Submits a black background and gray outer and white inner one-unit border fills at the stored geometry.  
 Does not render widgets or child overlays, or check the stored container visibility flag.

**Parameters:**
- `drawContext`: graphics context receiving the fill operations

### setFocused {#com.jsmacrosce.wagyourgui.overlays.OverlayContainer_setFocused-GuiEventListener-}

```js
setFocused(GuiEventListener focused): void
```

Forwards the focus target unchanged to the parent; `null` is forwarded to clear focus.

**Parameters:**
- `focused`: listener to focus, or `null` to clear focus
