Skip to content

Class OverlayContext

Definition

Namespace: StardewUI.Overlays
Assembly: StardewUI.dll

The context of an overlay, e.g. the active overlays for a particular menu or other non-overlay UI.

public class OverlayContext

Inheritance
Object ⇦ OverlayContext

Members

Constructors

Name Description
OverlayContext()

Properties

Name Description
Current The ambient context for the UI root that is currently being displayed or handling events.
Front Gets the overlay at the front of the stack.

Methods

Name Description
BackToFront() Iterates the stack from the back/bottom/least-recent overlay to the front/top/most-recent.
FrontToBack() Iterates the stack from the front/top/most-recent overlay to the back/bottom/least-recent.
Pop() Removes the front-most overlay.
Push(IOverlay) Pushes an overlay to the front.
Remove(IOverlay) Removes a specific overlay from the stack, regardless of its position.

Events

Name Description
Pushed Event raised when an overlay is pushed to the front.

Details

Constructors

OverlayContext()

public OverlayContext();

Properties

Current

The ambient context for the UI root that is currently being displayed or handling events.

public static StardewUI.Overlays.OverlayContext Current { get; set; }
Property Value

OverlayContext


Front

Gets the overlay at the front of the stack.

public StardewUI.Overlays.IOverlay Front { get; }
Property Value

IOverlay


Methods

BackToFront()

Iterates the stack from the back/bottom/least-recent overlay to the front/top/most-recent.

public System.Collections.Generic.IEnumerable<StardewUI.Overlays.IOverlay> BackToFront();
Returns

IEnumerable<IOverlay>


FrontToBack()

Iterates the stack from the front/top/most-recent overlay to the back/bottom/least-recent.

public System.Collections.Generic.IEnumerable<StardewUI.Overlays.IOverlay> FrontToBack();
Returns

IEnumerable<IOverlay>


Pop()

Removes the front-most overlay.

public StardewUI.Overlays.IOverlay Pop();
Returns

IOverlay

The overlay previously at the front, or null if no overlays were active.


Push(IOverlay)

Pushes an overlay to the front.

public void Push(StardewUI.Overlays.IOverlay overlay);
Parameters

overlay   IOverlay
The overlay to display on top of the current UI and any other overlays.

Remarks

If the specified overlay is already in the stack, then it will be moved from its previous position to the front.


Remove(IOverlay)

Removes a specific overlay from the stack, regardless of its position.

public bool Remove(StardewUI.Overlays.IOverlay overlay);
Parameters

overlay   IOverlay
The overlay to remove.

Returns

Boolean

true if the overlay was removed; false if it was not active.

Remarks

This is most often invoked by an overlay needing to dismiss itself, e.g. an overlay with an "OK" or "Close" button.


Events

Pushed

Event raised when an overlay is pushed to the front.

public event EventHandler<System.EventArgs>? Pushed;
Event Type

EventHandler<EventArgs>

Remarks

This can either be a new overlay, or an overlay that was farther back and brought forward. After this event, the affected overlay will always be the Front.