Skip to main content

neon_crisp / Modules / utils/guiPopupManager / PopupParent

Class: PopupParent

utils/guiPopupManager.PopupParent

The PopupParent class manages communication between a popup parent and its child, including handling input focus and sending open/close messages. This class facilitates opening and closing popups, along with an optional callback mechanism for executing specific actions when a popup is opened or closed.

Table of contents​

Constructors​

Properties​

Methods​

Constructors​

constructor​

• new PopupParent(childUrl, handleFocus?): PopupParent

Creates a new PopupParent instance.

Parameters​

NameTypeDefault valueDescription
childUrlurlundefinedThe URL of the popup child.
handleFocus?booleantrueSpecifies whether input focus should be handled automatically.

Returns​

PopupParent

Defined in​

utils/guiPopupManager.ts:31

Properties​

childUrl​

• childUrl: url

Defined in​

utils/guiPopupManager.ts:18


handleFocus​

• handleFocus: boolean

Defined in​

utils/guiPopupManager.ts:19


openAndCloseCB​

• Optional openAndCloseCB: (opening: boolean, message?: Record<string, any>) => void

Optional callback function that gets triggered when the popup is opened or closed. This function receives two parameters: a boolean opening that indicates if the popup is opening (true) or closing (false), and an optional message object.

Type declaration​

▸ (opening, message?): void

Optional callback function that gets triggered when the popup is opened or closed. This function receives two parameters: a boolean opening that indicates if the popup is opening (true) or closing (false), and an optional message object.

Parameters​
NameType
openingboolean
message?Record<string, any>
Returns​

void

Defined in​

utils/guiPopupManager.ts:25

Methods​

close​

▸ close(message): void

Closes the popup and posts a 'close' message to the child. If handleFocus is true, the parent acquires input focus after closing the child.

Parameters​

NameTypeDescription
messageRecord<string, any>The message to send when closing the popup.

Returns​

void

Defined in​

utils/guiPopupManager.ts:82


onClose​

▸ onClose(message): void

Parameters​

NameType
messageRecord<string, any>

Returns​

void

Defined in​

utils/guiPopupManager.ts:92


on_message​

▸ on_message(message_id, message, sender): void

Handles incoming messages from the child. Closes the popup if a 'close' message is received.

Parameters​

NameTypeDescription
message_idhashThe identifier of the received message.
messageRecord<string, any>The message data.
senderurlThe URL of the sender.

Returns​

void

Example

this.popupManager = new PopupParent("/popup#popup")
export function on_message(this: props, message_id: hash, message: Record<string, any>, sender: url): void {
this.popupManager.on_message(message_id, message, sender)
}

Defined in​

utils/guiPopupManager.ts:55


open​

▸ open(message, openStyle): void

Opens the popup and posts an 'open' message to the child. If handleFocus is true, the parent releases input focus before opening the child.

Parameters​

NameTypeDescription
messageRecord<string, any>The message to send when opening the popup.
openStyleOpenStyleThe style in which the popup should be opened.

Returns​

void

Defined in​

utils/guiPopupManager.ts:67


setOpenAndCloseCB​

▸ setOpenAndCloseCB(cb): void

Sets the callback function to be triggered when the popup is opened or closed.

Parameters​

NameTypeDescription
cb(opening: boolean, message?: Record<string, any>) => voidThe callback function to be invoked.

Returns​

void

Defined in​

utils/guiPopupManager.ts:40