Skip to main content

PopupDialog

Based on game build 714014 | Last updated: 2026-03-09

Overview

PopupDialogScreen is a UI screen component that creates a themed popup dialog box. It inherits from Screen and uses reusable layout templates (TEMPLATES.CurlyWindow, TEMPLATES.BackgroundTint, TEMPLATES.ScreenRoot) to render title, body text, and interactive buttons. The appearance and behavior are customizable via style (e.g., light, dark, dark_wide) and size preset (e.g., small, medium, big, bigger).

Usage example

local PopupDialogScreen = require "screens/redux/popupdialog"

local dialog = PopupDialogScreen(
"Title",
"This is the dialog body text.",
{
{text="OK", fn=function() dialog:Close() end},
{text="Cancel", fn=function() dialog:Close() end},
},
nil, -- spacing_override (optional)
"medium", -- longness preset (optional)
"dark" -- style preset (optional)
)

TheFrontEnd:PushScreen(dialog)

Dependencies & tags

Components used: None identified.
Tags: None identified.

Properties

PropertyTypeDefault ValueDescription
longnesstableLENGTHS["small"]Contains height value selected from LENGTHS based on the longness constructor argument.
styletableSTYLES["dark"]Contains bgconstructor and text properties defining visual styling.
blackImageBackground tint overlay added to the screen.
prootWidgetRoot container widget for dialog elements.
dialogWidgetContainer returned by style.bgconstructor; holds dialog body and buttons.
buttonsarray{}Array of button definitions passed to ControllerFunctionsFromButtons.
oncontrol_fnfunctionController input handler derived from buttons.
gethelptext_fnfunctionFunction returning help text string, derived from buttons.
default_focusWidgetself.dialogWidget designated as the default focus target.

Main functions

OnControl(control, down)

  • Description: Handles UI control inputs (e.g., controller/D-Pad navigation). Delegates to both parent class and button-specific handler.
  • Parameters:
    control (string) — The control identifier (e.g., "accept", "cancel").
    down (boolean) — Whether the control was pressed (true) or released (false).
  • Returns: true if the input was handled; false otherwise.

Close()

  • Description: Removes the screen from the frontend stack, effectively closing the dialog.
  • Parameters: None.
  • Returns: Nothing.

GetHelpText()

  • Description: Returns the help text string for the currently focused UI element (e.g., button descriptions).
  • Parameters: None.
  • Returns: String — help text derived from button definitions. May be nil if no help text is defined.

Events & listeners

None identified.